Hey there!
Somehow when i insert stuff inside the DB i get it twice! Here's my model :
[code
class MyAccountCredits extends DataObject {
static $db = array (
"MemberID" => "Int",
"ProductID" => "Varchar(200)",
"Aantal" => "Int",
"Geldigtot" => "Date",
"Credits" => "Int"
);
}
and here i put it inside the database :
$producten = unserialize(Session::get('producten'));
$sMail = '';
$member = $this->Member();
$nextyear = date('Y-m-d',mktime(0, 0, 0, date("m"), date("d"), date("Y")+1));
foreach ($producten as $product) {
$sMail .= $product->product_aantal. ' x ' . $product->product.' totaal = '. $product->prijs_totaal.' <br>';
$oCredits = Object::create('MyAccountCredits');
$oCredits->MemberID = $member->ID;
$oCredits->ProductID = $product->ProductID;
$oCredits->Aantal = $product->product_aantal;
$oCredits->Geldigtot = $nextyear;
$oCredits->Credits = $product->credits;
$oCredits->write();
}
print $sMail;
when i submit 3 products, the string $sMail contains the 3 products. but in the db i get them twice. but strange enough like
ID Name
1 product 1
2 product 2
3 product 3
4 product 1
5 product 2
6 product 3
Why does the dataobject wants to insert the hole operation 2 times?
When i use ?previewwrite=1 i also see just 3 insert queries, but when i remove it, it inserts 6 times!
And when i use showqueries=1 is only see the 3 expected queries....
Cheers!