/** * @param string $table * @param string $idfield * @return $this */ protected function _init($table, $idfield = 'id') { $this->_table = $table; $this->_idfield = $idfield; self::$___id_field = $idfield; $this->describe(); return $this; }
public static function __autoload($classname) { // Se for uma classe do core... if (substr($classname, 0, 5) === 'core_') { $classpath = CORE_ROOT . "/classes/{$classname}.php"; // Após obter o caminho, inclui o arquivo if (!is_file($classpath)) { $classpath = self::get_path_fixed($classpath); $error = new core_error('CxFFF0', null, array('classname' => $classname, 'classpath' => $classpath)); $error->run_special_exception(); } require_once $classpath; return true; } // Localiza uma user class // Primeiro localiza a parte modular $classpath = self::get_modular_parts($classname, array('path_clip' => true, 'search_paths' => false, 'make_fullpath' => true)); // Feito isso, verifica qual será o complemento que será aplicado no fullpath switch ($classpath->clipped) { case 'model': $classpath->fullpath .= '/models'; break; case 'library': $classpath->fullpath .= '/libraries'; break; case 'exception': $classpath->fullpath .= '/exceptions'; break; } // O próximo passo é localizar o arquivo que será incluido $classpath_subdata = self::get_modular_parts($classpath->remains, array('start_dir' => $classpath->fullpath, 'search_modules' => false, 'make_fullpath' => true)); // Após obter o caminho, inclui o arquivo if (!is_file($classpath_subdata->fullpath)) { $error = new core_error('CxFFF1', null, array('classname' => $classname, 'classpath' => $classpath->fullpath)); $error->run_special_exception(); } // Inclui o arquivo self::do_require($classpath_subdata->fullpath); // Se for um modelo, é necessário iniciá-lo if ($classpath->clipped === 'model') { core_model::_get_instance($classname); } }
public function delete($id) { $result = array('status' => 'succ'); #判断栏目下是否存在子栏目 存在不可删 $issc = $this->count(array('parent' => $id)); if ($issc > 0) { $result['status'] = 'fail'; $result['msg'] = '该栏目下存在子栏目,删除失败!'; return $result; } $data = $this->getOne(array('id' => $id)); if ($data['isdel'] == 'false') { $result['status'] = 'fail'; $result['msg'] = '该栏目不允许删除,删除失败!'; return $result; } if ($result['status'] == 'succ') { parent::delete(array('id' => $id)); } return $result; }
public function __construct() { parent::__construct(); $this->_init('test', 'test_id'); }
function model($model_path, $load_id = null, $conn = null) { return core_model::_create_row($conn ? $conn : connection(), $model_path, $load_id); }
public function _beforeSave() { parent::_beforeSave(); $this->setData('name', strtolower($this->getData('name'))); }
public function __construct() { parent::__construct('flowze_ticket', 'ticket_id'); }
protected function _beforeSave() { parent::_beforeSave(); if (!$this->getData('activity_id')) { throw new Exception('Activity is empty'); } // if(!$this->getData('city_id')){ // throw new Exception('City is empty'); // } if (!$this->getData('user_id')) { if ($this->getData('imei')) { $user_id = $this->_getUserByImei($this->getData('imei')); $this->setData('user_id', $user_id); } else { throw new Exception('User is empty'); } } if (!$this->getData('date')) { throw new Exception('Date is empty'); } if (!$this->getData('lat')) { throw new Exception('Lat is empty'); } if (!$this->getData('long')) { throw new Exception('Long is empty'); } $this->_applyUserColor()->_validDate(); return $this; }
public function __construct() { parent::__construct('trade_point', 'trade_point_id'); }
public function __construct() { parent::__construct('user_role', 'role_id'); }
public function __construct() { parent::__construct('user', 'user_id'); }