Block with date and timestamp will not install
Permalink
I am building a custom block for a client; one that will be for conferences, so the block will need to contain information about when the conference opens and ends. This is my miniature version of the conference db.xml, but whether I use type="D" or "T" the result is an SQL error. Are "D" and "T" not supported? I've looked through a lot of the default installed blocks and don't see any dates being used.
mysqlt error: [1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT '', openDate DATETIME DEFAULT '0000-00-00 00:00:00', ove' at line 3] in EXECUTE("CREATE TABLE btConferences ( bID INTEGER UNSIGNED NOT NULL, title VARCHAR DEFAULT '', openDate DATETIME DEFAULT '0000-00-00 00:00:00', overview LONGTEXT DEFAULT '', PRIMARY KEY (bID) )")
<?xml version="1.0"?> <schema version="0.3"> <table name="btConferences"> <field name="bID" type="I"> <key /> <unsigned /> </field> <field name="title" type="C"> <default value="" /> </field> <field name="openDate" type="T"> <default value="0000-00-00 00:00:00"/> </field> <field name="openDate" type="T"> <default value="0000-00-00 00:00:00"/>
Viewing 15 lines of 21 lines. View entire code block.
This is a handy idea and I'll keep it in mind. Thanks. But I sure wish I could get type="D" to just work.
Have you tried the TS option? I want to say that we've used that before and it worked.
'TS' didn't work either, but I now think that it's not the types that are causing the problem. I think it's what I have the default values set to. I really wish there was better documentation on these db.xml files with more than just strings.
Man! This is so frustrating. Even your example above doesn't work:
I must be doing something very basic wrong, or there must be a setting that I'm missing... I cannot get the most basic db.xml file to load.
<?xml version="1.0"?> <schema version="0.3"> <table name="btConferences"> <field name="bID" type="I"> <key></key> <unsigned></unsigned> </field> <field name="title" type="C"></field> <field name="openDate" type="N"> <default value="0" ></default> <NOTNULL></NOTNULL> </field> <field name="overview" type="X2"></field> </table> </schema>
I must be doing something very basic wrong, or there must be a setting that I'm missing... I cannot get the most basic db.xml file to load.
Does this work?
If not, what happens when you try to install the block? Does it throw errors?
<?xml version="1.0"?> <schema version="0.3"> <table name="btConferences"> <field name="bID" type="I"> <key /> <unsigned /> </field> <field name="title" type="C" size="255"></field> <field name="openDate" type="N"> <default value="0" /> <notnull /> </field> <field name="overview" type="X2"></field> </table> </schema>
If not, what happens when you try to install the block? Does it throw errors?
It sort of works. The size is indeed required for the type C field. So that takes care of the MySQL errors. In addition, the date and timestamp fields are being created as well. So thats good.
However, installing the block now throws a fatal PHP error:
Then the block isn't loaded (it appears in the block type list with an install button) even though it does appear in the database table.
However, installing the block now throws a fatal PHP error:
Fatal error: Call to undefined method stdClass::isInternalBlockType() in /home/ndpcnorg/public_html/concrete/core/controllers/single_pages/dashboard/blocks/types.php on line 22"
Then the block isn't loaded (it appears in the block type list with an install button) even though it does appear in the database table.
This looks like an issue with something in the block code rather than with the db.xml, maybe it has the same name or handle as an internal block?
If you want to zip and PM me the code for the block I can try to help you work it out, otherwise I'd say double check all of the controller code and look for an error there.
If you want to zip and PM me the code for the block I can try to help you work it out, otherwise I'd say double check all of the controller code and look for an error there.
Your hunch was totally correct. I found a misspelling of the table name in the controller file! It now loads and seems to be work. Thanks so much for you help.
then store the strtotime value of the date/time.