import v2.0.0.0_RC3 | 2012-07-01
https://github.com/lucanos/CommunityID -> http://www.itadmins.net/archives/357
This commit is contained in:
@ -17,7 +17,7 @@
|
||||
* @subpackage Select
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Select.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
* @version $Id: Select.php 19155 2009-11-21 09:48:02Z mikaelkael $
|
||||
*/
|
||||
|
||||
|
||||
@ -173,7 +173,7 @@ class Zend_Db_Select
|
||||
*/
|
||||
public function getBind()
|
||||
{
|
||||
return $this->_bind;
|
||||
return $this->_bind;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -184,9 +184,9 @@ class Zend_Db_Select
|
||||
*/
|
||||
public function bind($bind)
|
||||
{
|
||||
$this->_bind = $bind;
|
||||
$this->_bind = $bind;
|
||||
|
||||
return $this;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -227,7 +227,7 @@ class Zend_Db_Select
|
||||
*/
|
||||
public function from($name, $cols = '*', $schema = null)
|
||||
{
|
||||
return $this->joinInner($name, null, $cols, $schema);
|
||||
return $this->_join(self::FROM, $name, null, $cols, $schema);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -741,7 +741,7 @@ class Zend_Db_Select
|
||||
*/
|
||||
protected function _join($type, $name, $cond, $cols, $schema = null)
|
||||
{
|
||||
if (!in_array($type, self::$_joinTypes)) {
|
||||
if (!in_array($type, self::$_joinTypes) && $type != self::FROM) {
|
||||
/**
|
||||
* @see Zend_Db_Select_Exception
|
||||
*/
|
||||
@ -786,6 +786,7 @@ class Zend_Db_Select
|
||||
list($schema, $tableName) = explode('.', $tableName);
|
||||
}
|
||||
|
||||
$lastFromCorrelationName = null;
|
||||
if (!empty($correlationName)) {
|
||||
if (array_key_exists($correlationName, $this->_parts[self::FROM])) {
|
||||
/**
|
||||
@ -795,16 +796,39 @@ class Zend_Db_Select
|
||||
throw new Zend_Db_Select_Exception("You cannot define a correlation name '$correlationName' more than once");
|
||||
}
|
||||
|
||||
if ($type == self::FROM) {
|
||||
// append this from after the last from joinType
|
||||
$tmpFromParts = $this->_parts[self::FROM];
|
||||
$this->_parts[self::FROM] = array();
|
||||
// move all the froms onto the stack
|
||||
while ($tmpFromParts) {
|
||||
$currentCorrelationName = key($tmpFromParts);
|
||||
if ($tmpFromParts[$currentCorrelationName]['joinType'] != self::FROM) {
|
||||
break;
|
||||
}
|
||||
$lastFromCorrelationName = $currentCorrelationName;
|
||||
$this->_parts[self::FROM][$currentCorrelationName] = array_shift($tmpFromParts);
|
||||
}
|
||||
} else {
|
||||
$tmpFromParts = array();
|
||||
}
|
||||
$this->_parts[self::FROM][$correlationName] = array(
|
||||
'joinType' => $type,
|
||||
'schema' => $schema,
|
||||
'tableName' => $tableName,
|
||||
'joinCondition' => $cond
|
||||
);
|
||||
);
|
||||
while ($tmpFromParts) {
|
||||
$currentCorrelationName = key($tmpFromParts);
|
||||
$this->_parts[self::FROM][$currentCorrelationName] = array_shift($tmpFromParts);
|
||||
}
|
||||
}
|
||||
|
||||
// add to the columns from this joined table
|
||||
$this->_tableCols($correlationName, $cols);
|
||||
if ($type == self::FROM && $lastFromCorrelationName == null) {
|
||||
$lastFromCorrelationName = true;
|
||||
}
|
||||
$this->_tableCols($correlationName, $cols, $lastFromCorrelationName);
|
||||
|
||||
return $this;
|
||||
}
|
||||
@ -878,9 +902,10 @@ class Zend_Db_Select
|
||||
* @param string $tbl The table/join the columns come from.
|
||||
* @param array|string $cols The list of columns; preferably as
|
||||
* an array, but possibly as a string containing one column.
|
||||
* @param bool|string True if it should be prepended, a correlation name if it should be inserted
|
||||
* @return void
|
||||
*/
|
||||
protected function _tableCols($correlationName, $cols)
|
||||
protected function _tableCols($correlationName, $cols, $afterCorrelationName = null)
|
||||
{
|
||||
if (!is_array($cols)) {
|
||||
$cols = array($cols);
|
||||
@ -890,6 +915,8 @@ class Zend_Db_Select
|
||||
$correlationName = '';
|
||||
}
|
||||
|
||||
$columnValues = array();
|
||||
|
||||
foreach (array_filter($cols) as $alias => $col) {
|
||||
$currentCorrelationName = $correlationName;
|
||||
if (is_string($col)) {
|
||||
@ -906,7 +933,38 @@ class Zend_Db_Select
|
||||
$col = $m[2];
|
||||
}
|
||||
}
|
||||
$this->_parts[self::COLUMNS][] = array($currentCorrelationName, $col, is_string($alias) ? $alias : null);
|
||||
$columnValues[] = array($currentCorrelationName, $col, is_string($alias) ? $alias : null);
|
||||
}
|
||||
|
||||
if ($columnValues) {
|
||||
|
||||
// should we attempt to prepend or insert these values?
|
||||
if ($afterCorrelationName === true || is_string($afterCorrelationName)) {
|
||||
$tmpColumns = $this->_parts[self::COLUMNS];
|
||||
$this->_parts[self::COLUMNS] = array();
|
||||
} else {
|
||||
$tmpColumns = array();
|
||||
}
|
||||
|
||||
// find the correlation name to insert after
|
||||
if (is_string($afterCorrelationName)) {
|
||||
while ($tmpColumns) {
|
||||
$this->_parts[self::COLUMNS][] = $currentColumn = array_shift($tmpColumns);
|
||||
if ($currentColumn[0] == $afterCorrelationName) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// apply current values to current stack
|
||||
foreach ($columnValues as $columnValue) {
|
||||
array_push($this->_parts[self::COLUMNS], $columnValue);
|
||||
}
|
||||
|
||||
// finish ensuring that all previous values are applied (if they exist)
|
||||
while ($tmpColumns) {
|
||||
array_push($this->_parts[self::COLUMNS], array_shift($tmpColumns));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1045,9 +1103,11 @@ class Zend_Db_Select
|
||||
foreach ($this->_parts[self::FROM] as $correlationName => $table) {
|
||||
$tmp = '';
|
||||
|
||||
$joinType = ($table['joinType'] == self::FROM) ? self::INNER_JOIN : $table['joinType'];
|
||||
|
||||
// Add join clause (if applicable)
|
||||
if (! empty($from)) {
|
||||
$tmp .= ' ' . strtoupper($table['joinType']) . ' ';
|
||||
$tmp .= ' ' . strtoupper($joinType) . ' ';
|
||||
}
|
||||
|
||||
$tmp .= $this->_getQuotedSchema($table['schema']);
|
||||
@ -1156,7 +1216,13 @@ class Zend_Db_Select
|
||||
$order = array();
|
||||
foreach ($this->_parts[self::ORDER] as $term) {
|
||||
if (is_array($term)) {
|
||||
$order[] = $this->_adapter->quoteIdentifier($term[0], true) . ' ' . $term[1];
|
||||
if(is_numeric($term[0]) && strval(intval($term[0])) == $term[0]) {
|
||||
$order[] = (int)trim($term[0]) . ' ' . $term[1];
|
||||
} else {
|
||||
$order[] = $this->_adapter->quoteIdentifier($term[0], true) . ' ' . $term[1];
|
||||
}
|
||||
} else if (is_numeric($term) && strval(intval($term)) == $term) {
|
||||
$order[] = (int)trim($term);
|
||||
} else {
|
||||
$order[] = $this->_adapter->quoteIdentifier($term, true);
|
||||
}
|
||||
@ -1180,8 +1246,7 @@ class Zend_Db_Select
|
||||
|
||||
if (!empty($this->_parts[self::LIMIT_OFFSET])) {
|
||||
$offset = (int) $this->_parts[self::LIMIT_OFFSET];
|
||||
// This should reduce to the max integer PHP can support
|
||||
$count = intval(9223372036854775807);
|
||||
$count = PHP_INT_MAX;
|
||||
}
|
||||
|
||||
if (!empty($this->_parts[self::LIMIT_COUNT])) {
|
||||
|
Reference in New Issue
Block a user