フィルタを使用してオブジェクトを選択した後にデータベースに挿入したいとします。ここでシルバーストライプが選択後にオブジェクトに保存されない
は私のコードです:
$dayMealType = $newCustomer->Diets()->first()->DietMealPlan()->first()->Days()->filter('Order',$request->postVar('updateData')['dayNr'])->first()->DayMealType()->filter("MealTypeID",$request->postVar('updateData')['MealTypeId'])->first()->Foods();
$food_tmp = new FoodMealPlan();
$food_tmp->Carbohydrates = $request->postVar('updateData')['carbohydrates'];
$dayMealType->add($food_tmp);
$dayMealType->write();
選択作品と、それは以下のようなオブジェクトを返す:食品と
object(ManyManyList)#102 (16) {
["joinTable":protected]=>
string(17) "DayMealType_Foods"
["localKey":protected]=>
string(14) "FoodMealPlanID"
["foreignKey":protected]=>
string(13) "DayMealTypeID"
["extraFields":protected]=>
array(0) {
}
["_compositeExtraFields":protected]=>
array(0) {
}
["dataClass":protected]=>
string(12) "FoodMealPlan"
["dataQuery":protected]=>
object(DataQuery)#98 (8) {
["dataClass":protected]=>
string(12) "FoodMealPlan"
["query":protected]=>
object(SQLQuery)#97 (12) {
["isDelete":protected]=>
bool(false)
["select":protected]=>
array(0) {
}
["groupby":protected]=>
array(0) {
}
["having":protected]=>
array(0) {
}
["distinct":protected]=>
bool(true)
["orderby":protected]=>
array(0) {
}
["limit":protected]=>
NULL
["where":protected]=>
array(1) {
[0]=>
array(1) {
[""DayMealType_Foods"."DayMealTypeID" = ?"]=>
array(1) {
[0]=>
int(26810)
}
}
}
["connective":protected]=>
string(3) "AND"
["from":protected]=>
array(2) {
["FoodMealPlan"]=>
string(14) ""FoodMealPlan""
["DayMealType_Foods"]=>
array(5) {
["type"]=>
string(5) "INNER"
["table"]=>
string(17) "DayMealType_Foods"
["filter"]=>
array(1) {
[0]=>
string(58) ""DayMealType_Foods"."FoodMealPlanID" = "FoodMealPlan"."ID""
}
["order"]=>
int(20)
["parameters"]=>
array(0) {
}
}
}
["replacementsOld":protected]=>
array(0) {
}
["replacementsNew":protected]=>
array(0) {
}
}
["collidingFields":protected]=>
array(0) {
}
["queriedColumns":"DataQuery":private]=>
NULL
["queryFinalised":"DataQuery":private]=>
bool(false)
["querySubclasses":protected]=>
bool(true)
["filterByClassName":protected]=>
bool(true)
["queryParams":"DataQuery":private]=>
array(3) {
["Component.ExtraFields"]=>
array(0) {
}
["Foreign.ID"]=>
int(26810)
["Foreign.Filter"]=>
array(1) {
[""DayMealType_Foods"."DayMealTypeID""]=>
int(26810)
}
}
}
["model":protected]=>
object(DataModel)#3 (1) {
["customDataLists":protected]=>
array(0) {
}
}
["inAlterDataQueryCall":protected]=>
bool(false)
["failover":protected]=>
NULL
["customisedObject":protected]=>
NULL
["objCache":"ViewableData":private]=>
array(0) {
}
["class"]=>
string(12) "ManyManyList"
["extension_instances":protected]=>
array(0) {
}
["beforeExtendCallbacks":protected]=>
array(0) {
}
["afterExtendCallbacks":protected]=>
array(0) {
}
}
クラスは、このようなものです:
class DayMealType extends DataObject
{
private static $db = array(
'Calories' => 'Int',
'Carbohydrates' => 'Int',
'Proteins' => 'Int',
'Lipids' => 'Int',
'Price' => 'Decimal'
);
private static $has_one = array(
"MealType" => "MealTypeDetails",
"DayDietMealPlan" => "DayDietMealPlan"
);
private static $many_many = array(
"Foods" => "FoodMealPlan"
);
private static $casting = array(
'FoodsList' => 'HTMLText'
);
それ関数write()の後にエラーを返します。
DBには書き込まれません。
エラーとは何ですか? – bummzack