我很难装载两次吊舱。
假设我加载了一个与另一个豆荚相关的豆荚,我们称之为子豆荚。在页面的后面,如果我尝试加载子pod,我将得到空结果。
实例
$pods = new Pod(\'customization_category\');
$pods->findRecords(array(\'select\' => "t.id, t.name", \'where\' => "t.id=$id"));
$pods->fetchRecord();
$entity = new customization_category_entity;
$entity->id = $pods->get_field(\'id\');
$entity->name = $pods->get_field(\'name\');
$entity->options = array();
// process options
$customization_option_model = new customization_option_model();
$options = $pods->get_field(\'options\');
foreach ($options as $v)
{
$entity->options[] = $customization_option_model->create_from_array($v);
}
return $entity;
customization\\u category在customization\\u option pod中有一个PICK字段。调用此代码加载customization\\u option pod(使用
$pods->get_field
), 如果下一步调用此代码,我将得到一个空数组:
function get_single($id)
{
echo "$id = $id<br/>";
$pod = new Pod(\'customization_option\', $id);
return $this->create_from_array($pod->fetchRecord());
}
function create_from_array($array)
{
$entity = new customization_option_entity();
$entity->id = $array[\'id\'];
$entity->name = $array[\'name\'];
$entity->selection_image = $array[\'selection_image\'];
$entity->layer_image = $array[\'layer_image\'];
$entity->price = $array[\'price\'];
echo \'<pre>entity=\'.print_r($entity, true).\'</pre>\';
return $entity;
}
当我加载customization\\u strategy pod时,上面的代码将加载,但稍后我再次调用它时(通过
get_single
功能),它将不工作。
谷歌搜索一无所获。有什么想法吗?