3067 Posts in 867 Topics by 649 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 192 Views |
-
NULL values in Live table

9 January 2013 at 7:39am
I'm having a slightly weird problem. I'm trying to create a dataobject that will appear as a page in the site tree.
The basic code is like this:
$product = new Product();
$product->Title = "Example";
$product->ProductNumber = 666;
$product->writeToStage('Stage');
$product->publish('Stage', 'Live');If I do that and then go and watch the site tree everything looks all peachy. The new product has been added as a new published page.
But if I have a look in the database tables I realize that while the Product draft table looks like its intended to all fields except the ID field in the Product_Live table is set to NULL.
So if I do a:
DataObject::get_one("Product", "ProductNumber = '666'");
It will return nothing as ProductNumber is NULL in the _Live table.
-
Re: NULL values in Live table

9 January 2013 at 10:23am Last edited: 9 January 2013 11:56am
It goes a little something like this:
class Product extends Page {
public static $db = array(
"ProductNumber" => "Text",
"Preamble" => "HTMLText",
"ProductDescription" => "HTMLText",
"OldItemID" => "Int",
"OldProduct_Description_X" => "HTMLText",
"OldImage_Product_Number" => "HTMLText",
"OldMID" => "Int",
"ForSale" => "boolean",
);public static $has_one = array(
"MainPic" => "Image"
);static $has_many = array(
"ProductPics" => "ProductPic"
);static $many_many = array(
'Markets' => 'Market',
"Accessories" => "Product",
"SpareParts" => "Product",
"SimilarProducts" => "Product",
"ProductContactPersons" => "ProductContactPerson",
);static $multilingual_fields = array(
"TechSpec", "Preamble", "ProductDescription", "OldProduct_Description_X",
);I've run out of both good and bad ideas now.
With a $product->write(); I can get it to the _Live table, but then it's not in the draft. I can't seem to have them both at the same time. Unless I go into the CMS and hit the Save & Publish button, because that takes care of it and moves it to _Live.
-
Re: NULL values in Live table

9 January 2013 at 11:55am
Forgot to mention that the data looks like its supposed to in Product_versions as well. It's just that damn _Live. Argh.
| 192 Views | ||
|
Page:
1
|
Go to Top |


