Exemplo n.º 1
0
 /**
  * @param array $columns
  *
  * @return static
  */
 public function columns(array $columns)
 {
     foreach ($columns as $name => $value) {
         $this->columns[$this->grammar->buildId($name)] = $value;
     }
     return $this;
 }
Exemplo n.º 2
0
 /**
  * @param array $parameters
  *
  * @return static
  * @throws Exception
  */
 public function execute($parameters = null)
 {
     if ($parameters !== null) {
         $parameters = array_intersect_key($parameters, $this->types);
         foreach ($this->placeholders as $i => $name) {
             $value =& $parameters[$name];
             if ($value === null) {
                 $this->bindValue($i + 1, null, Connection::PARAM_NULL);
             } else {
                 $type =& $this->types[$name];
                 if ($type === Connection::PARAM_INT) {
                     $value = (int) $value;
                 } elseif ($type === Connection::PARAM_DATE_TIME) {
                     $value = $this->grammar->buildDateTime($value);
                     $type = Connection::PARAM_STR;
                 } elseif ($type === Connection::PARAM_TIME) {
                     $value = $this->grammar->buildTime($value);
                     $type = Connection::PARAM_STR;
                 }
                 $this->bindValue($i + 1, $value, $type);
             }
         }
     }
     parent::execute();
     return $this;
 }
Exemplo n.º 3
0
 public function testBuildTime()
 {
     $date = new \DateTime();
     $expected = $date->format(Grammar::TIME_FORMAT);
     $this->assertEquals($expected, $this->grammar->buildTime($date));
     $this->assertEquals($expected, $this->grammar->buildTime($date->getTimestamp()));
     $this->assertEquals($expected, $this->grammar->buildTime($expected));
     $this->setExpectedException('InvalidArgumentException');
     $this->grammar->buildTime([]);
 }
Exemplo n.º 4
0
 /**
  * @param string $column
  * @param bool   $asc
  *
  * @return static
  */
 public function orderBy($column, $asc = true)
 {
     if ($asc) {
         $this->orders[] = $this->grammar->buildId($column) . ' ASC';
     } else {
         $this->orders[] = $this->grammar->buildId($column) . ' DESC';
     }
     return $this;
 }
Exemplo n.º 5
0
 /**
  * @param string $id
  *
  * @return string
  */
 public function quoteId($id)
 {
     return $this->grammar->buildId($id);
 }
Exemplo n.º 6
0
 /**
  * @param string $column
  * @param string $pattern
  *
  * @return static
  */
 public function orNotLike($column, $pattern)
 {
     $this->conditions[] = 'OR ' . $this->grammar->buildId($column) . ' NOT LIKE ' . $pattern;
     return $this;
 }