Exemplo n.º 1
0
 /**
  * Get SQL string for statement
  *
  * @param  null|PlatformInterface $platform If null, defaults to Sql92
  * @return string
  */
 public function getSqlString(PlatformInterface $platform = null)
 {
     $platform = $platform ?: $this->platform ?: new Sql92();
     list($table, $schema) = $this->table->getAll();
     $table = $platform->quoteIdentifier($table);
     if ($schema) {
         $table = $platform->quoteIdentifier($schema) . $platform->getIdentifierSeparator() . $table;
     }
     $data = $this->data;
     if (is_array($data)) {
         $setSql = array();
         foreach ($data as $column => $value) {
             if ($value instanceof Expression) {
                 $expr = $this->processExpression($value, $platform);
                 $setSql[] = $platform->quoteIdentifier($column) . ' = ' . $expr;
             } elseif ($value === null) {
                 $setSql[] = $platform->quoteIdentifier($column) . ' = NULL';
             } else {
                 $setSql[] = $platform->quoteIdentifier($column) . ' = ' . $platform->quoteValue($value);
             }
         }
         $data = implode(', ', $setSql);
     }
     $sql = sprintf($this->specifications[self::SPECIFICATION_UPDATE], $table, $data);
     if ($this->where->count() > 0) {
         $expr = $this->processExpression($this->where, $platform, null, 'where');
         $sql .= ' ' . sprintf($this->specifications[self::SPECIFICATION_WHERE], $expr);
     }
     return $sql;
 }
Exemplo n.º 2
0
 protected function processWhere(PlatformInterface $platform, DriverInterface $driver = null, Parameters $parameters = null)
 {
     if ($this->where->count() == 0) {
         return null;
     }
     $sql = $this->processExpression($this->where, $platform, $driver, $this->processInfo['paramPrefix'] . 'where', $parameters);
     return array($sql);
 }
Exemplo n.º 3
0
 /**
  * Get the SQL string, based on the platform
  * Platform defaults to Sql92 if none provided
  *
  * @param  null|PlatformInterface $platform
  * @return string
  */
 public function getSqlString(PlatformInterface $platform = null)
 {
     $platform = $platform ?: $this->platform ?: new Sql92();
     list($table, $schema) = $this->table->getAll();
     $table = $platform->quoteIdentifier($table);
     if ($schema) {
         $table = $platform->quoteIdentifier($schema) . $platform->getIdentifierSeparator() . $table;
     }
     $sql = sprintf($this->specifications[self::SPECIFICATION_DELETE], $table);
     if ($this->where->count() > 0) {
         $part = $this->processExpression($this->where, $platform, null, 'where');
         $sql .= ' ' . sprintf($this->specifications[self::SPECIFICATION_WHERE], $part);
     }
     return $sql;
 }