Ejemplo n.º 1
0
 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];
 }
Ejemplo n.º 2
0
 public function __construct(array $config = [])
 {
     if (!isset($config['dsn'])) {
         throw new \InvalidArgumentException('Invalid database config, require "dsn" key.');
     }
     parent::__construct($config);
 }
Ejemplo n.º 3
0
 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];
 }
Ejemplo n.º 4
0
 public function __construct(array $config = [])
 {
     parent::__construct(static::normalizeConfig($config));
 }