Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Attributes
Zend_Db_Table_Select Class Reference
Inheritance diagram for Zend_Db_Table_Select:
Zend_Db_Select

Public Member Functions

 __construct (Zend_Db_Table_Abstract $table)
 
 getTable ()
 
 setTable (Zend_Db_Table_Abstract $table)
 
 setIntegrityCheck ($flag=true)
 
 isReadOnly ()
 
 from ($name, $cols=self::SQL_WILDCARD, $schema=null)
 
 assemble ()
 
- Public Member Functions inherited from Zend_Db_Select
 __construct (Zend_Db_Adapter_Abstract $adapter)
 
 getBind ()
 
 bind ($bind)
 
 distinct ($flag=true)
 
 from ($name, $cols=' *', $schema=null)
 
 columns ($cols=' *', $correlationName=null)
 
 union ($select=array(), $type=self::SQL_UNION)
 
 join ($name, $cond, $cols=self::SQL_WILDCARD, $schema=null)
 
 joinInner ($name, $cond, $cols=self::SQL_WILDCARD, $schema=null)
 
 joinLeft ($name, $cond, $cols=self::SQL_WILDCARD, $schema=null)
 
 joinRight ($name, $cond, $cols=self::SQL_WILDCARD, $schema=null)
 
 joinFull ($name, $cond, $cols=self::SQL_WILDCARD, $schema=null)
 
 joinCross ($name, $cols=self::SQL_WILDCARD, $schema=null)
 
 joinNatural ($name, $cols=self::SQL_WILDCARD, $schema=null)
 
 where ($cond, $value=null, $type=null)
 
 orWhere ($cond, $value=null, $type=null)
 
 group ($spec)
 
 having ($cond, $value=null, $type=null)
 
 orHaving ($cond, $value=null, $type=null)
 
 order ($spec)
 
 limit ($count=null, $offset=null)
 
 limitPage ($page, $rowCount)
 
 forUpdate ($flag=true)
 
 getPart ($part)
 
 query ($fetchMode=null, $bind=array())
 
 assemble ()
 
 reset ($part=null)
 
 getAdapter ()
 
 _joinUsing ($type, $name, $cond, $cols=' *', $schema=null)
 
 __call ($method, array $args)
 
 __toString ()
 

Protected Attributes

 $_info
 
 $_integrityCheck = true
 
 $_table
 
- Protected Attributes inherited from Zend_Db_Select
 $_bind = array()
 
 $_adapter
 
 $_parts = array()
 
 $_tableCols = array()
 

Additional Inherited Members

- Data Fields inherited from Zend_Db_Select
const DISTINCT = 'distinct'
 
const COLUMNS = 'columns'
 
const FROM = 'from'
 
const UNION = 'union'
 
const WHERE = 'where'
 
const GROUP = 'group'
 
const HAVING = 'having'
 
const ORDER = 'order'
 
const LIMIT_COUNT = 'limitcount'
 
const LIMIT_OFFSET = 'limitoffset'
 
const FOR_UPDATE = 'forupdate'
 
const INNER_JOIN = 'inner join'
 
const LEFT_JOIN = 'left join'
 
const RIGHT_JOIN = 'right join'
 
const FULL_JOIN = 'full join'
 
const CROSS_JOIN = 'cross join'
 
const NATURAL_JOIN = 'natural join'
 
const SQL_WILDCARD = '*'
 
const SQL_SELECT = 'SELECT'
 
const SQL_UNION = 'UNION'
 
const SQL_UNION_ALL = 'UNION ALL'
 
const SQL_FROM = 'FROM'
 
const SQL_WHERE = 'WHERE'
 
const SQL_DISTINCT = 'DISTINCT'
 
const SQL_GROUP_BY = 'GROUP BY'
 
const SQL_ORDER_BY = 'ORDER BY'
 
const SQL_HAVING = 'HAVING'
 
const SQL_FOR_UPDATE = 'FOR UPDATE'
 
const SQL_AND = 'AND'
 
const SQL_AS = 'AS'
 
const SQL_OR = 'OR'
 
const SQL_ON = 'ON'
 
const SQL_ASC = 'ASC'
 
const SQL_DESC = 'DESC'
 
const REGEX_COLUMN_EXPR = '/^([\w]*\s*\(([^\(\)]|(?1))*\))$/'
 
const REGEX_COLUMN_EXPR_ORDER = '/^([\w]+\s*\(([^\(\)]|(?1))*\))$/'
 
const REGEX_COLUMN_EXPR_GROUP = '/^([\w]+\s*\(([^\(\)]|(?1))*\))$/'
 
const REGEX_SQL_COMMENTS
 
- Protected Member Functions inherited from Zend_Db_Select
 _join ($type, $name, $cond, $cols, $schema=null)
 
 _tableCols ($correlationName, $cols, $afterCorrelationName=null)
 
 _where ($condition, $value=null, $type=null, $bool=true)
 
 _getDummyTable ()
 
 _getQuotedSchema ($schema=null)
 
 _getQuotedTable ($tableName, $correlationName=null)
 
 _renderDistinct ($sql)
 
 _renderColumns ($sql)
 
 _renderFrom ($sql)
 
 _renderUnion ($sql)
 
 _renderWhere ($sql)
 
 _renderGroup ($sql)
 
 _renderHaving ($sql)
 
 _renderOrder ($sql)
 
 _renderLimitoffset ($sql)
 
 _renderForupdate ($sql)
 
- Static Protected Attributes inherited from Zend_Db_Select
static $_partsInit
 
static $_joinTypes
 
static $_unionTypes
 

Detailed Description

Definition at line 46 of file Select.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( Zend_Db_Table_Abstract  $table)

Class constructor

Parameters
Zend_Db_Table_Abstract$adapter

Definition at line 74 of file Select.php.

75  {
76  parent::__construct($table->getAdapter());
77 
78  $this->setTable($table);
79  }
setTable(Zend_Db_Table_Abstract $table)
Definition: Select.php:97
$table
Definition: trigger.php:14

Member Function Documentation

◆ assemble()

assemble ( )

Performs a validation on the select query before passing back to the parent class. Ensures that only columns from the primary Zend_Db_Table are returned in the result.

Returns
string|null This object as a SELECT string (or null if a string cannot be produced)

Definition at line 190 of file Select.php.

191  {
193  $primary = $this->_info[Zend_Db_Table_Abstract::NAME];
194  $schema = $this->_info[Zend_Db_Table_Abstract::SCHEMA];
195 
196 
197  if (count($this->_parts[self::UNION]) == 0) {
198 
199  // If no fields are specified we assume all fields from primary table
200  if (!count($fields)) {
201  $this->from($primary, self::SQL_WILDCARD, $schema);
203  }
204 
205  $from = $this->getPart(Zend_Db_Table_Select::FROM);
206 
207  if ($this->_integrityCheck !== false) {
208  foreach ($fields as $columnEntry) {
209  list($table, $column) = $columnEntry;
210 
211  // Check each column to ensure it only references the primary table
212  if ($column) {
213  if (!isset($from[$table]) || $from[$table]['tableName'] != $primary) {
214  #require_once 'Zend/Db/Table/Select/Exception.php';
215  throw new Zend_Db_Table_Select_Exception('Select query cannot join with another table');
216  }
217  }
218  }
219  }
220  }
221 
222  return parent::assemble();
223  }
from($name, $cols=self::SQL_WILDCARD, $schema=null)
Definition: Select.php:171
$fields
Definition: details.phtml:14
getPart($part)
Definition: Select.php:688
const FROM
Definition: Select.php:49
const COLUMNS
Definition: Select.php:48
$table
Definition: trigger.php:14

◆ from()

from (   $name,
  $cols = self::SQL_WILDCARD,
  $schema = null 
)

Adds a FROM table and optional columns to the query.

The table name can be expressed

Parameters
array | string | Zend_Db_Expr | Zend_Db_Table_Abstract$nameThe table name or an associative array relating table name to correlation name.
array | string | Zend_Db_Expr$colsThe columns to select from this table.
string$schemaThe schema name to specify, if any.
Returns
Zend_Db_Table_Select This Zend_Db_Table_Select object.

Definition at line 171 of file Select.php.

172  {
173  if ($name instanceof Zend_Db_Table_Abstract) {
174  $info = $name->info();
178  }
179  }
180 
181  return $this->joinInner($name, null, $cols, $schema);
182  }
joinInner($name, $cond, $cols=self::SQL_WILDCARD, $schema=null)
Definition: Select.php:355
foreach( $_productCollection as $_product)() ?>" class $info
Definition: listing.phtml:52
if(!isset($_GET['name'])) $name
Definition: log.php:14

◆ getTable()

getTable ( )

Return the table that created this select object

Returns
Zend_Db_Table_Abstract

Definition at line 86 of file Select.php.

87  {
88  return $this->_table;
89  }

◆ isReadOnly()

isReadOnly ( )

Tests query to determine if expressions or aliases columns exist.

Returns
boolean

Definition at line 126 of file Select.php.

127  {
128  $readOnly = false;
130  $cols = $this->_info[Zend_Db_Table_Abstract::COLS];
131 
132  if (!count($fields)) {
133  return $readOnly;
134  }
135 
136  foreach ($fields as $columnEntry) {
137  $column = $columnEntry[1];
138  $alias = $columnEntry[2];
139 
140  if ($alias !== null) {
141  $column = $alias;
142  }
143 
144  switch (true) {
145  case ($column == self::SQL_WILDCARD):
146  break;
147 
148  case ($column instanceof Zend_Db_Expr):
149  case (!in_array($column, $cols)):
150  $readOnly = true;
151  break 2;
152  }
153  }
154 
155  return $readOnly;
156  }
$fields
Definition: details.phtml:14
getPart($part)
Definition: Select.php:688
const COLUMNS
Definition: Select.php:48
if(!trim($html)) $alias
Definition: details.phtml:20

◆ setIntegrityCheck()

setIntegrityCheck (   $flag = true)

Sets the integrity check flag.

Setting this flag to false skips the checks for table joins, allowing 'hybrid' table rows to be created.

Parameters
Zend_Db_Table_Abstract$adapter
Returns
Zend_Db_Select This Zend_Db_Select object.

Definition at line 115 of file Select.php.

116  {
117  $this->_integrityCheck = $flag;
118  return $this;
119  }

◆ setTable()

setTable ( Zend_Db_Table_Abstract  $table)

Sets the primary table name and retrieves the table schema.

Parameters
Zend_Db_Table_Abstract$adapter
Returns
Zend_Db_Select This Zend_Db_Select object.

Definition at line 97 of file Select.php.

98  {
99  $this->_adapter = $table->getAdapter();
100  $this->_info = $table->info();
101  $this->_table = $table;
102 
103  return $this;
104  }
$table
Definition: trigger.php:14

Field Documentation

◆ $_info

$_info
protected

Definition at line 53 of file Select.php.

◆ $_integrityCheck

$_integrityCheck = true
protected

Definition at line 60 of file Select.php.

◆ $_table

$_table
protected

Definition at line 67 of file Select.php.


The documentation for this class was generated from the following file: