프로그래밍 방식으로 $ many_many/$ belongs_many_many 관계로 다른 하나에 DataObject를 추가하려고합니다. Silverstripe-3은 그 작업에 문제가있는 것 같습니다.Silverstripe S3 : many_many 관계로 추가하는 DataObject
//Object 1
<?php
class ProductSubCategory extends DataObject {
static $db = array(
'Name' => 'Text',
'Description' => 'Text',
'RemoteIndexId'=>'varchar',
'LegalName' => 'Text',
'CodeName' => 'Text'
);
static $many_many = array('Ingredients'=>'Ingredient');
function addIngredients($ingredientsArray){
foreach($ingredientsArray as $k=>$value){
$newIngredient = new Ingredient();
$newIngredient->RemoteIndexId = $value->id;
$newIngredient->Name = $value->name;
$newIngredient->CodeName = $value->code_name;
$newIngredient->Description = $value->description;
$this->Ingredients()->add($newIngredient);
}
}
}
//Object 2
<?php
class Ingredient extends DataObject {
static $db = array(
'Name' => 'Text',
'RemoteIndexId'=>'Varchar',
'ScientificName' => 'Text',
'Description'=>'Text',
'Percentage'=>'Varchar',
'CodeName'=>'Varchar'
);
static $belong_many_many = array('ProductSubCategory' => 'ProductSubCategory');
//....(some fields for the UI)...
}
문제 설명 : 1. 성분이 데이터베이스에 기록되지 않습니다. 2. 테이블 ProductSubCategory_Ingredient 레코드를 얻을 수 있지만,이 ProductSubCategoryID 만 ID를 포함, IngredientID하지 3. 내가
이 도와주세요 아무 소용로, 지금은 일에 대한 솔루션을 둘러보고있다
NO 오류 메시지!