Hi Everyone, hope you're all doing well. I've been using the fDatabase class for a while, and decided I wanted to learn a bit more about the fORM layer. I created a very basic site and a simple database, and everything seems correct, but the query won't execute. It seems Flourish is quoting the table name in SQL, which MySQL doesn't like. Pasting the generated SQL into a terminal also causes the error - but removing the quotes works fine!
USE flourish_test;
CREATE TABLE books (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
title VARCHAR(255) NOT NULL,
tscreated TIMESTAMP NOT NULL,
tsmodified TIMESTAMP NOT NULL,
PRIMARY KEY (id)
) TYPE=InnoDB DEFAULT CHARSET=utf8;
In my Book.php class:
class Book extends fActiveRecord {
protected function configure() {
// Automatically have Flourish set the creation & modified timestamps
fORMDate::configureDateCreatedColumn( $this, 'tscreated' );
fORMDate::configureDateUpdatedColumn( $this, 'tsmodified' );
}
}
In my Flourish init.php, I have (along with the normal init stuff):
fORMDatabase::attach(
new fDatabase(
'mysql', 'flourish_test',
'flourish_test_un', 'flourish_test_pw', 'localhost'
)
);
fORM::mapClassToTable( 'Book', 'books' );
And in my one front end page, I have:
$test = new Book();
$test->setTitle( 'The Sun Also Rises' );
$test->store();
This throws the error (though I think incorrectly) from Flourish that "the noun could not be singularized" - but more importantly shows the query in the debug output as:
INSERT INTO "books" ("name", "tscreated", "tsmodified") VALUES ('The Sun Also Rises', '2011-07-29 14:02:13', '2011-07-29 14:02:13')
I've tried changing the class name, mappings, etc. to and from singular & plural thinking maybe Flourish was getting confused with that, but really that doesn't make sense since I followed the documentation's instructions on singular/plural naming, casing, etc. and also that the SQL is actually 100% accurate - except for the table name being quoted. I read as much as I could before posting this question. I'm losing my mind! Any ideas?