示例#1
0
 protected function processWhere(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null)
 {
     if ($this->where->count() == 0) {
         return;
     }
     return [$this->processExpression($this->where, $platform, $driver, $parameterContainer, 'where')];
 }
示例#2
0
 /**
  * Get SQL string for statement
  *
  * @param  null|PlatformInterface $adapterPlatform If null, defaults to Sql92
  * @return string
  */
 public function getSqlString(PlatformInterface $adapterPlatform = null)
 {
     $adapterPlatform = $adapterPlatform ?: new Sql92();
     $table = $this->table;
     $schema = null;
     // create quoted table name to use in update processing
     if ($table instanceof TableIdentifier) {
         list($table, $schema) = $table->getTableAndSchema();
     }
     $table = $adapterPlatform->quoteIdentifier($table);
     if ($schema) {
         $table = $adapterPlatform->quoteIdentifier($schema) . $adapterPlatform->getIdentifierSeparator() . $table;
     }
     $set = $this->set;
     if (is_array($set)) {
         $setSql = array();
         foreach ($set as $column => $value) {
             if ($value instanceof Expression) {
                 $exprData = $this->processExpression($value, $adapterPlatform);
                 $setSql[] = $adapterPlatform->quoteIdentifier($column) . ' = ' . $exprData->getSql();
             } elseif ($value === null) {
                 $setSql[] = $adapterPlatform->quoteIdentifier($column) . ' = NULL';
             } else {
                 $setSql[] = $adapterPlatform->quoteIdentifier($column) . ' = ' . $adapterPlatform->quoteValue($value);
             }
         }
         $set = implode(', ', $setSql);
     }
     $sql = sprintf($this->specifications[static::SPECIFICATION_UPDATE], $table, $set);
     if ($this->where->count() > 0) {
         $whereParts = $this->processExpression($this->where, $adapterPlatform, null, 'where');
         $sql .= ' ' . sprintf($this->specifications[static::SPECIFICATION_WHERE], $whereParts->getSql());
     }
     return $sql;
 }
示例#3
0
 protected function processWhere(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null)
 {
     if ($this->where->count() == 0) {
         return;
     }
     return sprintf($this->specifications[static::SPECIFICATION_WHERE], $this->processExpression($this->where, $platform, $driver, $parameterContainer, 'where'));
 }
示例#4
0
文件: Update.php 项目: haoyanfei/zf2
 /**
  * Get SQL string for statement
  *
  * @param  null|PlatformInterface $adapterPlatform If null, defaults to Sql92
  * @return string
  */
 public function getSqlString(PlatformInterface $adapterPlatform = null)
 {
     $adapterPlatform = $adapterPlatform ?: new Sql92();
     $table = $adapterPlatform->quoteIdentifier($this->table);
     $set = $this->set;
     if (is_array($set)) {
         $setSql = array();
         foreach ($set as $column => $value) {
             if ($value instanceof Expression) {
                 $exprData = $this->processExpression($value, $adapterPlatform);
                 $setSql[] = $adapterPlatform->quoteIdentifier($column) . ' = ' . $exprData->getSql();
             } elseif (is_null($value)) {
                 $setSql[] = $adapterPlatform->quoteIdentifier($column) . ' = NULL';
             } else {
                 $setSql[] = $adapterPlatform->quoteIdentifier($column) . ' = ' . $adapterPlatform->quoteValue($value);
             }
         }
         $set = implode(', ', $setSql);
     }
     $sql = sprintf($this->specifications[self::SPECIFICATION_UPDATE], $table, $set);
     if ($this->where->count() > 0) {
         $whereParts = $this->processExpression($this->where, $adapterPlatform, null, 'where');
         $sql .= ' ' . sprintf($this->specifications[self::SPECIFICATION_WHERE], $whereParts->getSql());
     }
     return $sql;
 }
示例#5
0
文件: Select.php 项目: Rovak/zf2
 protected function processWhere(PlatformInterface $platform, Adapter $adapter = null, ParameterContainer $parameterContainer = null)
 {
     if ($this->where->count() == 0) {
         return null;
     }
     $whereParts = $this->processExpression($this->where, $platform, $adapter, $this->processInfo['paramPrefix'] . 'where');
     if ($parameterContainer) {
         $parameterContainer->merge($whereParts->getParameterContainer());
     }
     return array($whereParts->getSql());
 }
示例#6
0
 protected function processWhere(PlatformInterface $platform, Adapter $adapter = null, ParameterContainer $parameterContainer = null)
 {
     if ($this->where->count() == 0) {
         return null;
     }
     $whereParts = $this->processExpression($this->where, $platform, $adapter ? $adapter->getDriver() : null, 'where');
     if (count($whereParts['parameters']) > 0) {
         $parameterContainer->merge($whereParts['parameters']);
     }
     return array($whereParts['sql']);
 }
示例#7
0
 /**
  * Get the SQL string, based on the platform
  *
  * Platform defaults to Sql92 if none provided
  *
  * @param  null|PlatformInterface $adapterPlatform
  * @return string
  */
 public function getSqlString(PlatformInterface $adapterPlatform = null)
 {
     $adapterPlatform = $adapterPlatform ?: new Sql92();
     $table = $adapterPlatform->quoteIdentifier($this->table);
     //        if ($this->schema != '') {
     //            $table = $platform->quoteIdentifier($this->schema) . $platform->getIdentifierSeparator() . $table;
     //        }
     $sql = sprintf($this->specifications[self::SPECIFICATION_DELETE], $table);
     if ($this->where->count() > 0) {
         $whereParts = $this->processExpression($this->where, $adapterPlatform, null, 'where');
         $sql .= ' ' . sprintf($this->specifications[self::SPECIFICATION_WHERE], $whereParts['sql']);
     }
     return $sql;
 }
示例#8
0
 /**
  * Get the SQL string, based on the platform
  *
  * Platform defaults to Sql92 if none provided
  *
  * @param  null|PlatformInterface $adapterPlatform
  * @return string
  */
 public function getSqlString(PlatformInterface $adapterPlatform = null)
 {
     $adapterPlatform = $adapterPlatform ?: new Sql92();
     $table = $this->table;
     $schema = null;
     // create quoted table name to use in delete processing
     if ($table instanceof TableIdentifier) {
         list($table, $schema) = $table->getTableAndSchema();
     }
     $table = $adapterPlatform->quoteIdentifier($table);
     if ($schema) {
         $table = $adapterPlatform->quoteIdentifier($schema) . $adapterPlatform->getIdentifierSeparator() . $table;
     }
     $sql = sprintf($this->specifications[static::SPECIFICATION_DELETE], $table);
     if ($this->where->count() > 0) {
         $whereParts = $this->processExpression($this->where, $adapterPlatform, null, 'where');
         $sql .= ' ' . sprintf($this->specifications[static::SPECIFICATION_WHERE], $whereParts->getSql());
     }
     return $sql;
 }
示例#9
0
文件: Update.php 项目: necrogami/zf2
    /**
     * Get SQL string for statement
     * 
     * @param  null|PlatformInterface $adapterPlatform If null, defaults to Sql92
     * @return string
     */
    public function getSqlString(PlatformInterface $adapterPlatform = null)
    {
        $adapterPlatform = ($adapterPlatform) ?: new Sql92;
        $table = $adapterPlatform->quoteIdentifier($this->table);

        $set = $this->set;
        if (is_array($set)) {
            $setSql = array();
            foreach ($set as $setName => $setValue) {
                $setSql[] = $adapterPlatform->quoteIdentifier($setName) . ' = ' . $adapterPlatform->quoteValue($setValue);
            }
            $set = implode(', ', $setSql);
        }

        $sql = sprintf($this->specifications[self::SPECIFICATION_UPDATE], $table, $set);
        if ($this->where->count() > 0) {
            $whereParts = $this->processExpression($this->where, $adapterPlatform, null, 'where');
            $sql .= ' ' . sprintf($this->specifications[self::SPECIFICATION_WHERE], $whereParts['sql']);
        }
        return $sql;
    }