本文整理汇总了PHP中Option::load方法的典型用法代码示例。如果您正苦于以下问题:PHP Option::load方法的具体用法?PHP Option::load怎么用?PHP Option::load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Option
的用法示例。
在下文中一共展示了Option::load方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
public static function load($thing)
{
$product = new Product();
$product->thing = $thing;
//members
$fields_raw = $product->thing->getData();
$tmpFields = array();
foreach ($fields_raw as $field) {
$tmpFields[$field->getKey()] = $field;
}
$product->fields = $tmpFields;
//variants
$thingVariants = $product->thing->getChildThings("variant");
$variants = array();
foreach ($thingVariants as $thingVariant) {
$variants[] = Variant::load($thingVariant);
}
$product->variants = $variants;
//options
$thingOptions = $product->thing->getChildThings("option");
$options = array();
foreach ($thingOptions as $thingOptions) {
$options[] = Option::load($thingOptions);
}
$product->options = $options;
return $product;
}
示例2: getByProduct
public function getByProduct($product)
{
$this->db->select();
$this->db->from('thing');
$this->db->where('thing_id', $product->getThing()->getId());
$query = $this->db->get();
$thingOptions = array();
foreach ($query->result() as $row) {
$thingOptions[] = Thing::loadFromRow($row);
}
//get options
$options = array();
foreach ($thingOptions as $thingOptions) {
$options[] = Option::load($thingOptions);
}
return $options;
}