Hello
I'm trying to extend Page. What I want is for each page to have a tab called 'Products' in the CMS, which would show a table of products. Each product would be one image and a title.
I think what I've done is correct but when I go to the admin I get:
[User Error] Couldn't run query: SELECT `Product`.*, `Product`.ID, if(`Product`.ClassName,`Product`.ClassName,'Product') AS RecordClassName, `0`, `1` FROM `Product` LIMIT 0,10 Unknown column '0' in 'field list'
What I did was edit mysite/code/Page.php and added to class Page:
$has_many = array( 'MyProducts' => 'Products');
Then I created mysite/code/Product.php :
class Product extends DataObject {
public static $db = array(
'ProductTitle' => 'Text'
);
public static $has_one = array(
'MyPage' => 'Page',
'ProductImage' => 'Image'
);
} //end class
I ran /db/build/?flush=1 and it did the update with no complaints.
I think this is right, with this model the each row of the database table would have a text field 'ProductTitle' and then an id of the page it's associated with and the id of an image.
When I go to the CMS I get the MySQL error above. Where is the `0` and `1` coming from?
I thought this might be due to there already being a 'Product' in Silverstripe so I changed 'Product' to 'GalleryItem' and I still get the same error.
Thanks for your help.
-david