protected function whereID(\Owl\Service $service, array $id) { $where = $params = []; $primary_key = $this->getPrimaryKey(); foreach ($primary_key as $key) { $where[] = $service->quoteIdentifier($key) . ' = ?'; $params[] = $id[$key]; } $where = implode(' AND ', $where); return [$where, $params]; }
public function __construct(array $config = []) { if (!isset($config['dsn'])) { throw new \InvalidArgumentException('Invalid database config, require "dsn" key.'); } parent::__construct($config); }
protected function whereID(\Owl\Service $service, $id) { $primary_key = $this->getPrimaryKey(); $key_count = count($primary_key); if ($key_count === 1 && !is_array($id)) { $key = $primary_key[0]; $id = [$key => $id]; } if (!is_array($id)) { throw new \Exception("{$this->class}: Illegal id value"); } $where = $params = []; foreach ($primary_key as $key) { $where[] = $service->quoteIdentifier($key) . ' = ?'; if (!isset($id[$key])) { throw new \Exception("{$this->class}: Illegal id value"); } $params[] = $id[$key]; } $where = implode(' AND ', $where); return [$where, $params]; }
public function __construct(array $config = []) { parent::__construct(static::normalizeConfig($config)); }