本文整理汇总了PHP中Condition::hydrate方法的典型用法代码示例。如果您正苦于以下问题:PHP Condition::hydrate方法的具体用法?PHP Condition::hydrate怎么用?PHP Condition::hydrate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Condition
的用法示例。
在下文中一共展示了Condition::hydrate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processImportConditions
public function processImportConditions($conditions, $id_lang)
{
$current_conditions = array();
$result = Db::getInstance()->ExecuteS('SELECT `id_ps_condition` FROM ' . _DB_PREFIX_ . 'condition');
foreach ($result as $row) {
$current_conditions[] = (int) $row['id_ps_condition'];
}
foreach ($conditions as $condition) {
if (isset($condition->id)) {
unset($condition->id);
}
try {
$cond = new Condition();
if (in_array($condition->id_ps_condition, $current_conditions)) {
$cond = new Condition(Condition::getIdByIdPs($condition->id_ps_condition));
unset($current_conditions[(int) array_search($condition->id_ps_condition, $current_conditions)]);
}
$cond->hydrate((array) $condition, (int) $id_lang);
$cond->date_upd = date('Y-m-d H:i:s', strtotime('-' . (int) $cond->calculation_detail . 'DAY'));
$cond->date_add = date('Y-m-d H:i:s');
$condition->calculation_detail = trim($condition->calculation_detail);
$cond->save(false, false);
if ($condition->calculation_type == 'hook' && !$this->isRegisteredInHook($condition->calculation_detail) && Validate::isHookName($condition->calculation_detail)) {
$this->registerHook($condition->calculation_detail);
}
unset($cond);
} catch (Exception $e) {
continue;
}
}
// Delete conditions that are not in the file anymore
foreach ($current_conditions as $id_ps_condition) {
$cond = new Condition(Condition::getIdByIdPs((int) $id_ps_condition));
$cond->delete();
}
}
示例2: processImportConditions
public function processImportConditions($conditions, $id_lang)
{
foreach ($conditions as $condition) {
try {
if (Condition::getIdByIdPs($condition->id_ps_condition)) {
continue;
}
//only add new condition, if already exist we continue
$cond = new Condition();
$cond->hydrate((array) $condition, (int) $id_lang);
$time = 86400;
if ($cond->calculation_type == 'time') {
$time = 86400 * (int) $cond->calculation_detail;
}
$cond->date_upd = date('Y-m-d H:i:s', time() - $time);
$cond->date_add = date('Y-m-d H:i:s');
$condition->calculation_detail = trim($condition->calculation_detail);
$cond->add(false);
if ($condition->calculation_type == 'hook' && !$this->isRegisteredInHook($condition->calculation_detail) && Validate::isHookName($condition->calculation_detail)) {
$this->registerHook($condition->calculation_detail);
}
unset($cond);
} catch (Exception $e) {
continue;
}
}
}