/** * 格式化默认的参数,会在每个类型的 `format()` 方法前执行 */ protected function check_config() { if (!isset($this->table_name) || !$this->table_name) { throw new InvalidArgumentException('orm ' . $this->class_name . '::$' . $this->key . ' config error, need table_name key.'); } if (!isset($this->config['field_name']) || !$this->config['field_name']) { $this->config['field_name'] = $this->key; } parent::check_config(); }
/** * 格式化默认的参数,会在每个类型的 `format()` 方法前执行 */ protected function check_config() { if (true === $this->config || 1 === $this->config) { # 对于id=true||1的字段,默认为主键 $this->config = array('pk' => true, 'is_readonly' => true, 'field_name' => $this->key, 'field_type' => 'bigint', 'is_virtual' => false); } elseif (null === $this->config) { $this->config = array('field_name' => $this->key, 'is_virtual' => false); } parent::check_config(); }
public function check_config() { if (is_string($this->config)) { if (preg_match('#^(xml|json|http|https)://(.*)$#', $this->config, $m)) { switch ($m[1]) { case 'xml': case 'json': $this->config = array('type' => $m[1], 'resource' => 'http://' . $m[2]); break; case 'http': case 'https': default: $this->config = array('type' => 'json', 'resource' => $m[1] . '://' . $m[2]); break; } } } parent::check_config(); }