quoteTable() public method

column quote can be configured by 'quote_table' option.
public quoteTable ( string $name ) : string
$name string table name
return string table name with/without quotes.
Esempio n. 1
0
 public function toSql(BaseDriver $driver, ArgumentArray $args)
 {
     $sql = 'INSERT';
     if (!empty($this->options)) {
         $sql .= $this->buildOptionClause();
     }
     $sql .= ' INTO ' . $driver->quoteTable($this->intoTable);
     // append partition clause if needed.
     $sql .= $this->buildPartitionClause($driver, $args);
     $valuesClauses = array();
     $varCnt = 1;
     // build columns
     $columns = $this->getColumnNames($driver);
     foreach ($this->values as $values) {
         $deflatedValues = array();
         foreach ($values as $key => $value) {
             $deflatedValues[] = $driver->deflate($value, $args);
         }
         $valuesClauses[] = '(' . join(',', $deflatedValues) . ')';
     }
     $sql .= ' (' . join(',', $columns) . ')' . ' VALUES ' . join(', ', $valuesClauses);
     // Check if RETURNING is supported
     if ($this->returning && $driver instanceof PgSQLDriver) {
         $sql .= ' RETURNING ' . join(',', $driver->quoteColumns($this->returning));
     }
     return $sql;
 }
Esempio n. 2
0
 public function buildFromClause(BaseDriver $driver, ArgumentArray $args)
 {
     $tableRefs = array();
     foreach ($this->from as $k => $v) {
         /* "column AS alias" OR just "column" */
         if (is_string($k)) {
             $sql = $driver->quoteTable($k) . ' AS ' . $v;
             if ($driver instanceof MySQLDriver) {
                 if ($this->definedIndexHint($v)) {
                     $sql .= $this->buildIndexHintClauseByTableRef($v, $driver, $args);
                 } elseif ($this->definedIndexHint($k)) {
                     $sql .= $this->buildIndexHintClauseByTableRef($k, $driver, $args);
                 }
             }
             $tableRefs[] = $sql;
         } elseif (is_integer($k) || is_numeric($k)) {
             $sql = $driver->quoteTable($v);
             if ($driver instanceof MySQLDriver && $this->definedIndexHint($v)) {
                 $sql .= $this->buildIndexHintClauseByTableRef($v, $driver, $args);
             }
             $tableRefs[] = $sql;
         }
     }
     if (!empty($tableRefs)) {
         return ' FROM ' . join(', ', $tableRefs);
     }
     return '';
 }
Esempio n. 3
0
 public function buildFromClause(BaseDriver $driver, ArgumentArray $args)
 {
     if (empty($this->updateTables)) {
         throw new IncompleteSettingsException('UpdateQuery requires at least one table to update.');
     }
     $tableRefs = array();
     foreach ($this->updateTables as $k => $alias) {
         /* "column AS alias" OR just "column" */
         if (is_string($k)) {
             $sql = $driver->quoteTable($k) . ' AS ' . $alias;
             if ($driver instanceof MySQLDriver) {
                 if ($this->definedIndexHint($alias)) {
                     $sql .= $this->buildIndexHintClauseByTableRef($alias, $driver, $args);
                 } elseif ($this->definedIndexHint($k)) {
                     $sql .= $this->buildIndexHintClauseByTableRef($k, $driver, $args);
                 }
             }
             $tableRefs[] = $sql;
         } elseif (is_integer($k) || is_numeric($k)) {
             $sql = $driver->quoteTable($alias);
             if ($driver instanceof MySQLDriver) {
                 if ($this->definedIndexHint($alias)) {
                     $sql .= $this->buildIndexHintClauseByTableRef($alias, $driver, $args);
                 }
             }
             $tableRefs[] = $sql;
         }
     }
     return ' ' . join(', ', $tableRefs);
 }
Esempio n. 4
0
 public function buildFromClause(BaseDriver $driver, ArgumentArray $args)
 {
     if (empty($this->deleteTables)) {
         throw new IncompleteSettingsException('DeleteQuery requires tables to delete.');
     }
     $tableRefs = array();
     foreach ($this->deleteTables as $k => $v) {
         /* "column AS alias" OR just "column" */
         if (is_string($k)) {
             $sql = $driver->quoteTable($k) . ' AS ' . $v;
             $tableRefs[] = $sql;
         } elseif (is_integer($k) || is_numeric($k)) {
             $sql = $driver->quoteTable($v);
             $tableRefs[] = $sql;
         }
     }
     return ' FROM ' . join(', ', $tableRefs);
 }