Class Varien_Db_Select

Description

Class for SQL SELECT generation and results.

Located in /Db/Select.php (line 34)

Zend_Db_Select
   |
   --Varien_Db_Select
Class Constant Summary
SQL_STRAIGHT_JOIN = 'STRAIGHT_JOIN'
STRAIGHT_JOIN = 'straightjoin'
STRAIGHT_JOIN_ON = 'straight_join'
TYPE_CONDITION = 'TYPE_CONDITION'
Method Summary
Varien_Db_Select __construct ( $adapter)
string crossUpdateFromSelect (string|array $table)
string deleteFromSelect (string $table)
string insertFromSelect (string $tableName, [array $fields = array()], [bool $onDuplicate = true])
string insertIgnoreFromSelect (string $tableName, [array $fields = array()])
Zend_Db_Select joinStraight (array|string|Zend_Db_Expr $name, string $cond, [array|string $cols = self::SQL_WILDCARD], [string $schema = null])
Varien_Db_Select setPart (string $part, mixed $value)
Zend_Db_Select useStraightJoin ([bool $flag = true])
Zend_Db_Select where (string $cond, [string $value = null], [constant $type = null])
bool _findTableInCond (string $table, string $cond)
string _renderStraightjoin (string $sql)
void _resetJoinLeft ()
Methods
Constructor __construct (line 47)

Class constructor

  • access: public
Varien_Db_Select __construct ( $adapter)
  • Zend_Db_Adapter_Abstract $adapter
crossUpdateFromSelect (line 242)

Cross Table Update From Current select

  • access: public
string crossUpdateFromSelect (string|array $table)
  • string|array $table
deleteFromSelect (line 368)

Retrieve DELETE query from select

  • access: public
string deleteFromSelect (string $table)
  • string $table: The table name or alias
insertFromSelect (line 309)

Insert to table from current select

  • access: public
string insertFromSelect (string $tableName, [array $fields = array()], [bool $onDuplicate = true])
  • string $tableName
  • array $fields
  • bool $onDuplicate
insertIgnoreFromSelect (line 348)

Generate INSERT IGNORE query to the table from current select

  • access: public
string insertIgnoreFromSelect (string $tableName, [array $fields = array()])
  • string $tableName
  • array $fields
joinStraight (line 415)

Add a STRAIGHT_JOIN table and colums to the query (MySQL only).

STRAIGHT_JOIN is similar to JOIN, except that the left table is always read before the right table. This can be used for those (few) cases for which the join optimizer puts the tables in the wrong order

The $name and $cols parameters follow the same logic as described in the from() method.

  • return: This Zend_Db_Select object.
  • access: public
Zend_Db_Select joinStraight (array|string|Zend_Db_Expr $name, string $cond, [array|string $cols = self::SQL_WILDCARD], [string $schema = null])
  • array|string|Zend_Db_Expr $name: The table name.
  • string $cond: Join on this condition.
  • array|string $cols: The columns to select from the joined table.
  • string $schema: The database name to specify, if any.
resetJoinLeft (line 111)

Reset unused LEFT JOIN(s)

  • access: public
Varien_Db_Select resetJoinLeft ()
setPart (line 390)

Modify (hack) part of the structured information for the currect query

  • access: public
Varien_Db_Select setPart (string $part, mixed $value)
  • string $part
  • mixed $value
useStraightJoin (line 426)

Use a STRAIGHT_JOIN for the SQL Select

  • return: This Zend_Db_Select object.
  • access: public
Zend_Db_Select useStraightJoin ([bool $flag = true])
  • bool $flag: Whether or not the SELECT use STRAIGHT_JOIN (default true).
where (line 88)

Adds a WHERE condition to the query by AND.

If a value is passed as the second param, it will be quoted and replaced into the condition wherever a question-mark appears. Array values are quoted and comma-separated.

  1.  // simplest but non-secure
  2.  $select->where("id = $id");
  3.  
  4.  // secure (ID is quoted but matched anyway)
  5.  $select->where('id = ?'$id);
  6.  
  7.  // alternatively, with named binding
  8.  $select->where('id = :id');

Note that it is more correct to use named bindings in your queries for values other than strings. When you use named bindings, don't forget to pass the values when actually making a query:

  1.  $db->fetchAll($selectarray('id' => 5));

  • return: This Zend_Db_Select object.
  • access: public
Zend_Db_Select where (string $cond, [string $value = null], [constant $type = null])
  • string $cond: The WHERE condition.
  • string $value: OPTIONAL A single value to quote into the condition.
  • constant $type: OPTIONAL The type of the given value
_findTableInCond (line 200)

Find table name in condition (where, column)

  • access: protected
bool _findTableInCond (string $table, string $cond)
  • string $table
  • string $cond
_renderStraightjoin (line 438)

Render STRAIGHT_JOIN clause

  • access: protected
string _renderStraightjoin (string $sql)
  • string $sql: SQL query
_resetJoinLeft (line 168)
  • access: protected
void _resetJoinLeft ()
Class Constants
SQL_STRAIGHT_JOIN = 'STRAIGHT_JOIN' (line 40)
STRAIGHT_JOIN = 'straightjoin' (line 39)
STRAIGHT_JOIN_ON = 'straight_join' (line 38)
TYPE_CONDITION = 'TYPE_CONDITION' (line 36)

Documentation generated on Fri, 11 Feb 2011 16:53:23 +0200 by phpDocumentor 1.4.3