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:
2019-07-17 22:31:04 +02:00
parent 38c146901c
commit 2f397f01f7
2677 changed files with 296182 additions and 45159 deletions

View File

@ -17,7 +17,7 @@
* @subpackage Adapter
* @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: Abstract.php 17702 2009-08-20 23:54:16Z yoshida@zend.co.jp $
* @version $Id: Abstract.php 19115 2009-11-20 17:41:25Z matthew $
*/
@ -173,10 +173,10 @@ abstract class Zend_Db_Adapter_Abstract
$config = $config->toArray();
} else {
/**
* @see Zend_Db_Exception
* @see Zend_Db_Adapter_Exception
*/
require_once 'Zend/Db/Exception.php';
throw new Zend_Db_Exception('Adapter parameters must be in an array or a Zend_Config object');
require_once 'Zend/Db/Adapter/Exception.php';
throw new Zend_Db_Adapter_Exception('Adapter parameters must be in an array or a Zend_Config object');
}
}
@ -902,7 +902,7 @@ abstract class Zend_Db_Adapter_Abstract
return str_replace('?', $this->quote($value, $type), $text);
} else {
while ($count > 0) {
if (strpos($text, '?') != false) {
if (strpos($text, '?') !== false) {
$text = substr_replace($text, $this->quote($value, $type), strpos($text, '?'), 1);
}
--$count;

View File

@ -17,7 +17,7 @@
* @subpackage Adapter
* @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: Db2.php 16541 2009-07-07 06:59:03Z bkarwin $
* @version $Id: Db2.php 18951 2009-11-12 16:26:19Z alexander $
*
*/
@ -373,7 +373,7 @@ class Zend_Db_Adapter_Db2 extends Zend_Db_Adapter_Abstract
if ($schemaName === null && $this->_config['schema'] != null) {
$schemaName = $this->_config['schema'];
}
if (!$this->_isI5) {
$sql = "SELECT DISTINCT c.tabschema, c.tabname, c.colname, c.colno,
@ -402,14 +402,14 @@ class Zend_Db_Adapter_Db2 extends Zend_Db_Adapter_Abstract
$sql = "SELECT DISTINCT C.TABLE_SCHEMA, C.TABLE_NAME, C.COLUMN_NAME, C.ORDINAL_POSITION,
C.DATA_TYPE, C.COLUMN_DEFAULT, C.NULLS ,C.LENGTH, C.SCALE, LEFT(C.IDENTITY,1),
LEFT(tc.TYPE, 1) AS tabconsttype, k.COLSEQ
FROM QSYS2.SYSCOLUMNS C
FROM QSYS2.SYSCOLUMNS C
LEFT JOIN (QSYS2.syskeycst k JOIN QSYS2.SYSCST tc
ON (k.TABLE_SCHEMA = tc.TABLE_SCHEMA
AND k.TABLE_NAME = tc.TABLE_NAME
AND LEFT(tc.type,1) = 'P'))
AND LEFT(tc.type,1) = 'P'))
ON (C.TABLE_SCHEMA = k.TABLE_SCHEMA
AND C.TABLE_NAME = k.TABLE_NAME
AND C.COLUMN_NAME = k.COLUMN_NAME)
AND C.COLUMN_NAME = k.COLUMN_NAME)
WHERE "
. $this->quoteInto('UPPER(C.TABLE_NAME) = UPPER(?)', $tableName);

View File

@ -17,7 +17,7 @@
* @subpackage Adapter
* @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: Exception.php 16541 2009-07-07 06:59:03Z bkarwin $
* @version $Id: Exception.php 17860 2009-08-27 22:48:48Z beberlei $
*/
/**
@ -45,6 +45,11 @@ class Zend_Db_Adapter_Exception extends Zend_Db_Exception
parent::__construct($message);
}
public function hasChainedException()
{
return ($this->_chainedException!==null);
}
public function getChainedException()
{
return $this->_chainedException;

View File

@ -17,7 +17,7 @@
* @subpackage Adapter
* @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: Oracle.php 16920 2009-07-21 13:32:28Z ralph $
* @version $Id: Oracle.php 19048 2009-11-19 18:15:05Z mikaelkael $
*/
/**
@ -81,7 +81,7 @@ class Zend_Db_Adapter_Oracle extends Zend_Db_Adapter_Abstract
/**
* @var integer
*/
protected $_execute_mode = OCI_COMMIT_ON_SUCCESS;
protected $_execute_mode = null;
/**
* Default class name for a DB statement.
@ -119,8 +119,10 @@ class Zend_Db_Adapter_Oracle extends Zend_Db_Adapter_Abstract
throw new Zend_Db_Adapter_Oracle_Exception('The OCI8 extension is required for this adapter but the extension is not loaded');
}
$this->_setExecuteMode(OCI_COMMIT_ON_SUCCESS);
$connectionFuncName = ($this->_config['persistent'] == true) ? 'oci_pconnect' : 'oci_connect';
$this->_connection = @$connectionFuncName(
$this->_config['username'],
$this->_config['password'],
@ -358,7 +360,7 @@ class Zend_Db_Adapter_Oracle extends Zend_Db_Adapter_Abstract
TC.DATA_SCALE, TC.DATA_PRECISION, C.CONSTRAINT_TYPE, CC.POSITION
FROM ALL_TAB_COLUMNS TC
LEFT JOIN (ALL_CONS_COLUMNS CC JOIN ALL_CONSTRAINTS C
ON (CC.CONSTRAINT_NAME = C.CONSTRAINT_NAME AND CC.TABLE_NAME = C.TABLE_NAME AND C.CONSTRAINT_TYPE = 'P'))
ON (CC.CONSTRAINT_NAME = C.CONSTRAINT_NAME AND CC.TABLE_NAME = C.TABLE_NAME AND CC.OWNER = C.OWNER AND C.CONSTRAINT_TYPE = 'P'))
ON TC.TABLE_NAME = CC.TABLE_NAME AND TC.COLUMN_NAME = CC.COLUMN_NAME
WHERE UPPER(TC.TABLE_NAME) = UPPER(:TBNAME)";
$bind[':TBNAME'] = $tableName;

View File

@ -17,7 +17,7 @@
* @subpackage Adapter
* @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: Abstract.php 16920 2009-07-21 13:32:28Z ralph $
* @version $Id: Abstract.php 18951 2009-11-12 16:26:19Z alexander $
*/
@ -119,7 +119,7 @@ abstract class Zend_Db_Adapter_Pdo_Abstract extends Zend_Db_Adapter_Abstract
if (isset($this->_config['persistent']) && ($this->_config['persistent'] == true)) {
$this->_config['driver_options'][PDO::ATTR_PERSISTENT] = true;
}
try {
$this->_connection = new PDO(
$dsn,
@ -141,7 +141,7 @@ abstract class Zend_Db_Adapter_Pdo_Abstract extends Zend_Db_Adapter_Abstract
* @see Zend_Db_Adapter_Exception
*/
require_once 'Zend/Db/Adapter/Exception.php';
throw new Zend_Db_Adapter_Exception($e->getMessage());
throw new Zend_Db_Adapter_Exception($e->getMessage(), $e);
}
}
@ -241,7 +241,7 @@ abstract class Zend_Db_Adapter_Pdo_Abstract extends Zend_Db_Adapter_Abstract
* @see Zend_Db_Statement_Exception
*/
require_once 'Zend/Db/Statement/Exception.php';
throw new Zend_Db_Statement_Exception($e->getMessage());
throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
}
}
@ -258,10 +258,10 @@ abstract class Zend_Db_Adapter_Pdo_Abstract extends Zend_Db_Adapter_Abstract
if ($sql instanceof Zend_Db_Select) {
$sql = $sql->assemble();
}
try {
$affected = $this->getConnection()->exec($sql);
if ($affected === false) {
$errorInfo = $this->getConnection()->errorInfo();
/**
@ -270,14 +270,14 @@ abstract class Zend_Db_Adapter_Pdo_Abstract extends Zend_Db_Adapter_Abstract
require_once 'Zend/Db/Adapter/Exception.php';
throw new Zend_Db_Adapter_Exception($errorInfo[2]);
}
return $affected;
} catch (PDOException $e) {
/**
* @see Zend_Db_Adapter_Exception
*/
require_once 'Zend/Db/Adapter/Exception.php';
throw new Zend_Db_Adapter_Exception($e->getMessage());
throw new Zend_Db_Adapter_Exception($e->getMessage(), $e);
}
}

View File

@ -17,7 +17,7 @@
* @subpackage Adapter
* @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: Mssql.php 17792 2009-08-24 16:18:02Z ralph $
* @version $Id: Mssql.php 18951 2009-11-12 16:26:19Z alexander $
*/
@ -254,7 +254,7 @@ class Zend_Db_Adapter_Pdo_Mssql extends Zend_Db_Adapter_Pdo_Abstract
if ($schemaName != null) {
$sql .= ", @table_owner = " . $this->quoteIdentifier($schemaName, true);
}
$stmt = $this->query($sql);
$primaryKeysResult = $stmt->fetchAll(Zend_Db::FETCH_NUM);
$primaryKeyColumn = array();
@ -335,46 +335,46 @@ class Zend_Db_Adapter_Pdo_Mssql extends Zend_Db_Adapter_Pdo_Abstract
'SELECT $1TOP ' . ($count+$offset) . ' ',
$sql
);
if ($offset > 0) {
$orderby = stristr($sql, 'ORDER BY');
if ($orderby !== false) {
$orderParts = explode(',', substr($orderby, 8));
$pregReplaceCount = null;
$orderbyInverseParts = array();
foreach ($orderParts as $orderPart) {
$orderPart = rtrim($orderPart);
$inv = preg_replace('/\s+desc$/i', ' ASC', $orderPart, 1, $pregReplaceCount);
if ($pregReplaceCount) {
$orderbyInverseParts[] = $inv;
continue;
}
$inv = preg_replace('/\s+asc$/i', ' DESC', $orderPart, 1, $pregReplaceCount);
if ($pregReplaceCount) {
$orderbyInverseParts[] = $inv;
continue;
} else {
$orderbyInverseParts[] = $orderPart . ' DESC';
}
}
$orderbyInverse = 'ORDER BY ' . implode(', ', $orderbyInverseParts);
}
$sql = 'SELECT * FROM (SELECT TOP ' . $count . ' * FROM (' . $sql . ') AS inner_tbl';
if ($orderby !== false) {
$sql .= ' ' . $orderbyInverse . ' ';
}
$sql .= ') AS outer_tbl';
if ($orderby !== false) {
$sql .= ' ' . $orderby;
}
$orderby = stristr($sql, 'ORDER BY');
if ($orderby !== false) {
$orderParts = explode(',', substr($orderby, 8));
$pregReplaceCount = null;
$orderbyInverseParts = array();
foreach ($orderParts as $orderPart) {
$orderPart = rtrim($orderPart);
$inv = preg_replace('/\s+desc$/i', ' ASC', $orderPart, 1, $pregReplaceCount);
if ($pregReplaceCount) {
$orderbyInverseParts[] = $inv;
continue;
}
$inv = preg_replace('/\s+asc$/i', ' DESC', $orderPart, 1, $pregReplaceCount);
if ($pregReplaceCount) {
$orderbyInverseParts[] = $inv;
continue;
} else {
$orderbyInverseParts[] = $orderPart . ' DESC';
}
}
$orderbyInverse = 'ORDER BY ' . implode(', ', $orderbyInverseParts);
}
$sql = 'SELECT * FROM (SELECT TOP ' . $count . ' * FROM (' . $sql . ') AS inner_tbl';
if ($orderby !== false) {
$sql .= ' ' . $orderbyInverse . ' ';
}
$sql .= ') AS outer_tbl';
if ($orderby !== false) {
$sql .= ' ' . $orderby;
}
}
return $sql;
}

View File

@ -17,7 +17,7 @@
* @subpackage Adapter
* @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: Oci.php 16203 2009-06-21 18:56:17Z thomas $
* @version $Id: Oci.php 19048 2009-11-19 18:15:05Z mikaelkael $
*/
@ -186,7 +186,7 @@ class Zend_Db_Adapter_Pdo_Oci extends Zend_Db_Adapter_Pdo_Abstract
TC.DATA_SCALE, TC.DATA_PRECISION, C.CONSTRAINT_TYPE, CC.POSITION
FROM ALL_TAB_COLUMNS TC
LEFT JOIN (ALL_CONS_COLUMNS CC JOIN ALL_CONSTRAINTS C
ON (CC.CONSTRAINT_NAME = C.CONSTRAINT_NAME AND CC.TABLE_NAME = C.TABLE_NAME AND C.CONSTRAINT_TYPE = 'P'))
ON (CC.CONSTRAINT_NAME = C.CONSTRAINT_NAME AND CC.TABLE_NAME = C.TABLE_NAME AND CC.OWNER = C.OWNER AND C.CONSTRAINT_TYPE = 'P'))
ON TC.TABLE_NAME = CC.TABLE_NAME AND TC.COLUMN_NAME = CC.COLUMN_NAME
WHERE UPPER(TC.TABLE_NAME) = UPPER(:TBNAME)";
$bind[':TBNAME'] = $tableName;

View File

@ -17,7 +17,7 @@
* @subpackage Adapter
* @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: Pgsql.php 16732 2009-07-15 12:44:36Z yoshida@zend.co.jp $
* @version $Id: Pgsql.php 19051 2009-11-19 18:27:53Z mikaelkael $
*/
@ -99,19 +99,14 @@ class Zend_Db_Adapter_Pdo_Pgsql extends Zend_Db_Adapter_Pdo_Abstract
*/
public function listTables()
{
// @todo use a better query with joins instead of subqueries
$sql = "SELECT c.relname AS table_name "
. "FROM pg_class c, pg_user u "
. "WHERE c.relowner = u.usesysid AND c.relkind = 'r' "
. "AND NOT EXISTS (SELECT 1 FROM pg_views WHERE viewname = c.relname) "
. "AND c.relname !~ '^(pg_|sql_)' "
. "UNION "
. "SELECT c.relname AS table_name "
. "FROM pg_class c "
. "WHERE c.relkind = 'r' "
. "AND NOT EXISTS (SELECT 1 FROM pg_views WHERE viewname = c.relname) "
. "AND NOT EXISTS (SELECT 1 FROM pg_user WHERE usesysid = c.relowner) "
. "AND c.relname !~ '^pg_'";
$sql = "SELECT c.relname AS table_name "
. "FROM pg_catalog.pg_class c "
. "JOIN pg_catalog.pg_roles r ON r.oid = c.relowner "
. "LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace "
. "WHERE n.nspname <> 'pg_catalog' "
. "AND n.nspname !~ '^pg_toast' "
. "AND pg_catalog.pg_table_is_visible(c.oid) "
. "AND c.relkind = 'r' ";
return $this->fetchCol($sql);
}
@ -194,6 +189,7 @@ class Zend_Db_Adapter_Pdo_Pgsql extends Zend_Db_Adapter_Pdo_Abstract
$desc = array();
foreach ($result as $key => $row) {
$defaultValue = $row[$default_value];
if ($row[$type] == 'varchar') {
if (preg_match('/character varying(?:\((\d+)\))?/', $row[$complete_type], $matches)) {
if (isset($matches[1])) {
@ -202,6 +198,9 @@ class Zend_Db_Adapter_Pdo_Pgsql extends Zend_Db_Adapter_Pdo_Abstract
$row[$length] = null; // unlimited
}
}
if (preg_match("/^'(.*?)'::character varying$/", $defaultValue, $matches)) {
$defaultValue = $matches[1];
}
}
list($primary, $primaryPosition, $identity) = array(false, null, false);
if ($row[$contype] == 'p') {
@ -215,7 +214,7 @@ class Zend_Db_Adapter_Pdo_Pgsql extends Zend_Db_Adapter_Pdo_Abstract
'COLUMN_NAME' => $this->foldCase($row[$colname]),
'COLUMN_POSITION' => $row[$attnum],
'DATA_TYPE' => $row[$type],
'DEFAULT' => $row[$default_value],
'DEFAULT' => $defaultValue,
'NULLABLE' => (bool) ($row[$notnull] != 't'),
'LENGTH' => $row[$length],
'SCALE' => null, // @todo

View File

@ -17,7 +17,7 @@
* @subpackage Adapter
* @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: Sqlite.php 16203 2009-06-21 18:56:17Z thomas $
* @version $Id: Sqlite.php 18951 2009-11-12 16:26:19Z alexander $
*/
@ -197,12 +197,14 @@ class Zend_Db_Adapter_Pdo_Sqlite extends Zend_Db_Adapter_Pdo_Abstract
*/
public function describeTable($tableName, $schemaName = null)
{
$sql = 'PRAGMA ';
if ($schemaName) {
$sql = "PRAGMA $schemaName.table_info($tableName)";
} else {
$sql = "PRAGMA table_info($tableName)";
$sql .= $this->quoteIdentifier($schemaName) . '.';
}
$sql .= 'table_info('.$this->quoteIdentifier($tableName).')';
$stmt = $this->query($sql);
/**

View File

@ -17,7 +17,7 @@
* @subpackage Profiler
* @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: Firebug.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: Firebug.php 18951 2009-11-12 16:26:19Z alexander $
*/
/** Zend_Db_Profiler */
@ -31,7 +31,7 @@ require_once 'Zend/Wildfire/Plugin/FirePhp/TableMessage.php';
/**
* Writes DB events as log messages to the Firebug Console via FirePHP.
*
*
* @category Zend
* @package Zend_Db
* @subpackage Profiler
@ -45,25 +45,25 @@ class Zend_Db_Profiler_Firebug extends Zend_Db_Profiler
* @var string
*/
protected $_label = null;
/**
* The label template for this profiler
* @var string
*/
protected $_label_template = '%label% (%totalCount% @ %totalDuration% sec)';
/**
* The message envelope holding the profiling summary
* @var Zend_Wildfire_Plugin_FirePhp_TableMessage
*/
protected $_message = null;
/**
* The total time taken for all profiled queries.
* @var float
*/
protected $_totalElapsedTime = 0;
/**
* Constructor
*
@ -90,7 +90,7 @@ class Zend_Db_Profiler_Firebug extends Zend_Db_Profiler
parent::setEnabled($enable);
if ($this->getEnabled()) {
if (!$this->_message) {
$this->_message = new Zend_Wildfire_Plugin_FirePhp_TableMessage($this->_label);
$this->_message->setBuffered(true);
@ -106,7 +106,7 @@ class Zend_Db_Profiler_Firebug extends Zend_Db_Profiler
$this->_message->setDestroy(true);
$this->_message = null;
}
}
return $this;
@ -122,7 +122,7 @@ class Zend_Db_Profiler_Firebug extends Zend_Db_Profiler
public function queryEnd($queryId)
{
parent::queryEnd($queryId);
if (!$this->getEnabled()) {
return;
}
@ -130,19 +130,19 @@ class Zend_Db_Profiler_Firebug extends Zend_Db_Profiler
$this->_message->setDestroy(false);
$profile = $this->getQueryProfile($queryId);
$this->_totalElapsedTime += $profile->getElapsedSecs();
$this->_message->addRow(array((string)round($profile->getElapsedSecs(),5),
$profile->getQuery(),
($params=$profile->getQueryParams())?$params:null));
$this->updateMessageLabel();
}
/**
* Update the label of the message holding the profile info.
*
*
* @return void
*/
protected function updateMessageLabel()

View File

@ -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])) {

View File

@ -17,7 +17,7 @@
* @subpackage Statement
* @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: Statement.php 16541 2009-07-07 06:59:03Z bkarwin $
* @version $Id: Statement.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -42,6 +42,11 @@ require_once 'Zend/Db/Statement/Interface.php';
abstract class Zend_Db_Statement implements Zend_Db_Statement_Interface
{
/**
* @var resource|object The driver level statement object/resource
*/
protected $_stmt = null;
/**
* @var Zend_Db_Adapter_Abstract
*/
@ -112,6 +117,17 @@ abstract class Zend_Db_Statement implements Zend_Db_Statement_Interface
$this->_queryId = $this->_adapter->getProfiler()->queryStart($sql);
}
/**
* Internal method called by abstract statment constructor to setup
* the driver level statement
*
* @return void
*/
protected function _prepare($sql)
{
return;
}
/**
* @param string $sql
* @return void
@ -456,4 +472,14 @@ abstract class Zend_Db_Statement implements Zend_Db_Statement_Interface
{
return $this->_adapter;
}
/**
* Gets the resource or object setup by the
* _parse
* @return unknown_type
*/
public function getDriverStatement()
{
return $this->_stmt;
}
}

View File

@ -17,7 +17,7 @@
* @subpackage Statement
* @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: Db2.php 16541 2009-07-07 06:59:03Z bkarwin $
* @version $Id: Db2.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -35,10 +35,6 @@ require_once 'Zend/Db/Statement.php';
*/
class Zend_Db_Statement_Db2 extends Zend_Db_Statement
{
/**
* Statement resource handle.
*/
protected $_stmt = null;
/**
* Column names.
@ -158,7 +154,7 @@ class Zend_Db_Statement_Db2 extends Zend_Db_Statement
$error = db2_stmt_error();
if ($error === '') {
return false;
return false;
}
return $error;
@ -172,10 +168,10 @@ class Zend_Db_Statement_Db2 extends Zend_Db_Statement
*/
public function errorInfo()
{
$error = $this->errorCode();
if ($error === false){
return false;
}
$error = $this->errorCode();
if ($error === false){
return false;
}
/*
* Return three-valued array like PDO. But DB2 does not distinguish

View File

@ -17,7 +17,7 @@
* @subpackage Statement
* @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: Exception.php 16541 2009-07-07 06:59:03Z bkarwin $
* @version $Id: Exception.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -36,4 +36,38 @@ require_once 'Zend/Db/Exception.php';
*/
class Zend_Db_Statement_Exception extends Zend_Db_Exception
{
/**
* @var Exception
*/
protected $_chainedException = null;
/**
* @param string $message
* @param string|int $code
* @param Exception $chainedException
*/
public function __construct($message = null, $code = null, Exception $chainedException=null)
{
$this->message = $message;
$this->code = $code;
$this->_chainedException = $chainedException;
}
/**
* Check if this general exception has a specific database driver specific exception nested inside.
*
* @return bool
*/
public function hasChainedException()
{
return ($this->_chainedException!==null);
}
/**
* @return Exception|null
*/
public function getChainedException()
{
return $this->_chainedException;
}
}

View File

@ -17,7 +17,7 @@
* @subpackage Statement
* @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: Mysqli.php 17693 2009-08-20 16:34:59Z jimbojsb $
* @version $Id: Mysqli.php 18951 2009-11-12 16:26:19Z alexander $
*/
@ -26,7 +26,7 @@
*/
require_once 'Zend/Db/Statement.php';
/**
* Extends for Mysqli
*
@ -39,13 +39,6 @@ require_once 'Zend/Db/Statement.php';
class Zend_Db_Statement_Mysqli extends Zend_Db_Statement
{
/**
* The mysqli_stmt object.
*
* @var mysqli_stmt
*/
protected $_stmt;
/**
* Column names.
*
@ -282,12 +275,12 @@ class Zend_Db_Statement_Mysqli extends Zend_Db_Statement
// fetch the next result
$retval = $this->_stmt->fetch();
switch ($retval) {
case null: // end of data
case false: // error occurred
$this->_stmt->reset();
return $retval;
default:
// fallthrough
case null: // end of data
case false: // error occurred
$this->_stmt->reset();
return false;
default:
// fallthrough
}
// make sure we have a fetch mode

View File

@ -17,7 +17,7 @@
* @subpackage Statement
* @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: Oracle.php 16541 2009-07-07 06:59:03Z bkarwin $
* @version $Id: Oracle.php 18636 2009-10-17 05:44:41Z ralph $
*/
/**
@ -37,11 +37,6 @@ require_once 'Zend/Db/Statement.php';
class Zend_Db_Statement_Oracle extends Zend_Db_Statement
{
/**
* The connection_stmt object.
*/
protected $_stmt;
/**
* Column names.
*/
@ -234,18 +229,11 @@ class Zend_Db_Statement_Oracle extends Zend_Db_Statement
public function _execute(array $params = null)
{
$connection = $this->_adapter->getConnection();
if (!$this->_stmt) {
return false;
}
if (! $this->_stmt) {
/**
* @see Zend_Db_Adapter_Oracle_Exception
*/
require_once 'Zend/Db/Statement/Oracle/Exception.php';
throw new Zend_Db_Statement_Oracle_Exception(oci_error($connection));
}
if ($params !== null) {
if (!is_array($params)) {
$params = array($params);

View File

@ -17,7 +17,7 @@
* @subpackage Statement
* @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: Pdo.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: Pdo.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -40,13 +40,6 @@ require_once 'Zend/Db/Statement.php';
class Zend_Db_Statement_Pdo extends Zend_Db_Statement implements IteratorAggregate
{
/**
* The statement object.
*
* @var PDOStatement
*/
protected $_stmt;
/**
* @var int
*/
@ -65,7 +58,7 @@ class Zend_Db_Statement_Pdo extends Zend_Db_Statement implements IteratorAggrega
$this->_stmt = $this->_adapter->getConnection()->prepare($sql);
} catch (PDOException $e) {
require_once 'Zend/Db/Statement/Exception.php';
throw new Zend_Db_Statement_Exception($e->getMessage());
throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
}
}
@ -89,7 +82,7 @@ class Zend_Db_Statement_Pdo extends Zend_Db_Statement implements IteratorAggrega
}
} catch (PDOException $e) {
require_once 'Zend/Db/Statement/Exception.php';
throw new Zend_Db_Statement_Exception($e->getMessage());
throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
}
}
@ -121,7 +114,7 @@ class Zend_Db_Statement_Pdo extends Zend_Db_Statement implements IteratorAggrega
return $this->_stmt->bindParam($parameter, $variable, $type, $length, $options);
} catch (PDOException $e) {
require_once 'Zend/Db/Statement/Exception.php';
throw new Zend_Db_Statement_Exception($e->getMessage());
throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
}
}
@ -139,6 +132,9 @@ class Zend_Db_Statement_Pdo extends Zend_Db_Statement implements IteratorAggrega
if (is_string($parameter) && $parameter[0] != ':') {
$parameter = ":$parameter";
}
$this->_bindParam[$parameter] = $value;
try {
if ($type === null) {
return $this->_stmt->bindValue($parameter, $value);
@ -147,7 +143,7 @@ class Zend_Db_Statement_Pdo extends Zend_Db_Statement implements IteratorAggrega
}
} catch (PDOException $e) {
require_once 'Zend/Db/Statement/Exception.php';
throw new Zend_Db_Statement_Exception($e->getMessage());
throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
}
}
@ -163,7 +159,7 @@ class Zend_Db_Statement_Pdo extends Zend_Db_Statement implements IteratorAggrega
return $this->_stmt->closeCursor();
} catch (PDOException $e) {
require_once 'Zend/Db/Statement/Exception.php';
throw new Zend_Db_Statement_Exception($e->getMessage());
throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
}
}
@ -180,7 +176,7 @@ class Zend_Db_Statement_Pdo extends Zend_Db_Statement implements IteratorAggrega
return $this->_stmt->columnCount();
} catch (PDOException $e) {
require_once 'Zend/Db/Statement/Exception.php';
throw new Zend_Db_Statement_Exception($e->getMessage());
throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
}
}
@ -197,7 +193,7 @@ class Zend_Db_Statement_Pdo extends Zend_Db_Statement implements IteratorAggrega
return $this->_stmt->errorCode();
} catch (PDOException $e) {
require_once 'Zend/Db/Statement/Exception.php';
throw new Zend_Db_Statement_Exception($e->getMessage());
throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
}
}
@ -214,7 +210,7 @@ class Zend_Db_Statement_Pdo extends Zend_Db_Statement implements IteratorAggrega
return $this->_stmt->errorInfo();
} catch (PDOException $e) {
require_once 'Zend/Db/Statement/Exception.php';
throw new Zend_Db_Statement_Exception($e->getMessage());
throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
}
}
@ -235,7 +231,7 @@ class Zend_Db_Statement_Pdo extends Zend_Db_Statement implements IteratorAggrega
}
} catch (PDOException $e) {
require_once 'Zend/Db/Statement/Exception.php';
throw new Zend_Db_Statement_Exception($e->getMessage());
throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
}
}
@ -257,7 +253,7 @@ class Zend_Db_Statement_Pdo extends Zend_Db_Statement implements IteratorAggrega
return $this->_stmt->fetch($style, $cursor, $offset);
} catch (PDOException $e) {
require_once 'Zend/Db/Statement/Exception.php';
throw new Zend_Db_Statement_Exception($e->getMessage());
throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
}
}
@ -295,7 +291,7 @@ class Zend_Db_Statement_Pdo extends Zend_Db_Statement implements IteratorAggrega
}
} catch (PDOException $e) {
require_once 'Zend/Db/Statement/Exception.php';
throw new Zend_Db_Statement_Exception($e->getMessage());
throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
}
}
@ -312,7 +308,7 @@ class Zend_Db_Statement_Pdo extends Zend_Db_Statement implements IteratorAggrega
return $this->_stmt->fetchColumn($col);
} catch (PDOException $e) {
require_once 'Zend/Db/Statement/Exception.php';
throw new Zend_Db_Statement_Exception($e->getMessage());
throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
}
}
@ -330,7 +326,7 @@ class Zend_Db_Statement_Pdo extends Zend_Db_Statement implements IteratorAggrega
return $this->_stmt->fetchObject($class, $config);
} catch (PDOException $e) {
require_once 'Zend/Db/Statement/Exception.php';
throw new Zend_Db_Statement_Exception($e->getMessage());
throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
}
}
@ -347,7 +343,7 @@ class Zend_Db_Statement_Pdo extends Zend_Db_Statement implements IteratorAggrega
return $this->_stmt->getAttribute($key);
} catch (PDOException $e) {
require_once 'Zend/Db/Statement/Exception.php';
throw new Zend_Db_Statement_Exception($e->getMessage());
throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
}
}
@ -364,7 +360,7 @@ class Zend_Db_Statement_Pdo extends Zend_Db_Statement implements IteratorAggrega
return $this->_stmt->getColumnMeta($column);
} catch (PDOException $e) {
require_once 'Zend/Db/Statement/Exception.php';
throw new Zend_Db_Statement_Exception($e->getMessage());
throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
}
}
@ -382,7 +378,7 @@ class Zend_Db_Statement_Pdo extends Zend_Db_Statement implements IteratorAggrega
return $this->_stmt->nextRowset();
} catch (PDOException $e) {
require_once 'Zend/Db/Statement/Exception.php';
throw new Zend_Db_Statement_Exception($e->getMessage());
throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
}
}
@ -400,7 +396,7 @@ class Zend_Db_Statement_Pdo extends Zend_Db_Statement implements IteratorAggrega
return $this->_stmt->rowCount();
} catch (PDOException $e) {
require_once 'Zend/Db/Statement/Exception.php';
throw new Zend_Db_Statement_Exception($e->getMessage());
throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
}
}
@ -418,7 +414,7 @@ class Zend_Db_Statement_Pdo extends Zend_Db_Statement implements IteratorAggrega
return $this->_stmt->setAttribute($key, $val);
} catch (PDOException $e) {
require_once 'Zend/Db/Statement/Exception.php';
throw new Zend_Db_Statement_Exception($e->getMessage());
throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
}
}
@ -436,7 +432,7 @@ class Zend_Db_Statement_Pdo extends Zend_Db_Statement implements IteratorAggrega
return $this->_stmt->setFetchMode($mode);
} catch (PDOException $e) {
require_once 'Zend/Db/Statement/Exception.php';
throw new Zend_Db_Statement_Exception($e->getMessage());
throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
}
}

View File

@ -17,7 +17,7 @@
* @subpackage Statement
* @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: Ibm.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: Ibm.php 17860 2009-08-27 22:48:48Z beberlei $
*/
/**
@ -87,7 +87,7 @@ class Zend_Db_Statement_Pdo_Ibm extends Zend_Db_Statement_Pdo
}
} catch (PDOException $e) {
require_once 'Zend/Db/Statement/Exception.php';
throw new Zend_Db_Statement_Exception($e->getMessage());
throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
}
}

View File

@ -35,10 +35,6 @@ require_once 'Zend/Db/Statement.php';
*/
class Zend_Db_Statement_Sqlsrv extends Zend_Db_Statement
{
/**
* The connection_stmt object.
*/
protected $_stmt;
/**
* The connection_stmt object original string.

View File

@ -17,7 +17,7 @@
* @subpackage Table
* @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: Table.php 16733 2009-07-15 13:16:50Z ralph $
* @version $Id: Table.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -41,20 +41,20 @@ require_once 'Zend/Db/Table/Definition.php';
*/
class Zend_Db_Table extends Zend_Db_Table_Abstract
{
/**
* __construct() - For concrete implementation of Zend_Db_Table
*
* @param string|array $config string can reference a Zend_Registry key for a db adapter
* OR it can refernece the name of a table
* @param unknown_type $definition
* @param unknown_type $definition
*/
public function __construct($config = array(), $definition = null)
{
if ($definition !== null && is_array($definition)) {
$definition = new Zend_Db_Table_Definition($definition);
}
if (is_string($config)) {
if (Zend_Registry::isRegistered($config)) {
trigger_error(__CLASS__ . '::' . __METHOD__ . '(\'registryName\') is not valid usage of Zend_Db_Table, '
@ -73,12 +73,12 @@ class Zend_Db_Table extends Zend_Db_Table_Abstract
}
}
}
parent::__construct($config);
}
}

View File

@ -17,7 +17,7 @@
* @subpackage Table
* @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: Abstract.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: Abstract.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -93,14 +93,14 @@ abstract class Zend_Db_Table_Abstract
* @var unknown_type
*/
protected $_definition = null;
/**
* Optional definition config name used in concrete implementation
*
* @var string
*/
protected $_definitionConfigName = null;
/**
* Default cache for information provided by the adapter's describeTable() method.
*
@ -326,7 +326,7 @@ abstract class Zend_Db_Table_Abstract
return $this;
}
/**
* setDefinition()
*
@ -338,7 +338,7 @@ abstract class Zend_Db_Table_Abstract
$this->_definition = $definition;
return $this;
}
/**
* getDefinition()
*
@ -348,7 +348,7 @@ abstract class Zend_Db_Table_Abstract
{
return $this->_definition;
}
/**
* setDefinitionConfigName()
*
@ -360,7 +360,7 @@ abstract class Zend_Db_Table_Abstract
$this->_definitionConfigName = $definitionConfigName;
return $this;
}
/**
* getDefinitionConfigName()
*
@ -803,7 +803,16 @@ abstract class Zend_Db_Table_Abstract
// If $this has a metadata cache
if (null !== $this->_metadataCache) {
// Define the cache identifier where the metadata are saved
$cacheId = md5("$this->_schema.$this->_name");
//get db configuration
$dbConfig = $this->_db->getConfig();
// Define the cache identifier where the metadata are saved
$cacheId = md5( // port:host/dbname:schema.table (based on availabilty)
(isset($dbConfig['options']['port']) ? ':'.$dbConfig['options']['port'] : null)
. (isset($dbConfig['options']['host']) ? ':'.$dbConfig['options']['host'] : null)
. '/'.$dbConfig['dbname'].':'.$this->_schema.'.'.$this->_name
);
}
// If $this has no metadata cache or metadata cache misses
@ -969,8 +978,8 @@ abstract class Zend_Db_Table_Abstract
self::COLS => $this->_getCols(),
self::PRIMARY => (array) $this->_primary,
self::METADATA => $this->_metadata,
self::ROW_CLASS => $this->_rowClass,
self::ROWSET_CLASS => $this->_rowsetClass,
self::ROW_CLASS => $this->getRowClass(),
self::ROWSET_CLASS => $this->getRowsetClass(),
self::REFERENCE_MAP => $this->_referenceMap,
self::DEPENDENT_TABLES => $this->_dependentTables,
self::SEQUENCE => $this->_sequence
@ -1228,6 +1237,7 @@ abstract class Zend_Db_Table_Abstract
$whereList = array();
$numberTerms = 0;
foreach ($args as $keyPosition => $keyValues) {
$keyValuesCount = count($keyValues);
// Coerce the values to an array.
// Don't simply typecast to array, because the values
// might be Zend_Db_Expr objects.
@ -1235,12 +1245,13 @@ abstract class Zend_Db_Table_Abstract
$keyValues = array($keyValues);
}
if ($numberTerms == 0) {
$numberTerms = count($keyValues);
} else if (count($keyValues) != $numberTerms) {
$numberTerms = $keyValuesCount;
} else if ($keyValuesCount != $numberTerms) {
require_once 'Zend/Db/Table/Exception.php';
throw new Zend_Db_Table_Exception("Missing value(s) for the primary key");
}
for ($i = 0; $i < count($keyValues); ++$i) {
$keyValues = array_values($keyValues);
for ($i = 0; $i < $keyValuesCount; ++$i) {
if (!isset($whereList[$i])) {
$whereList[$i] = array();
}
@ -1266,6 +1277,16 @@ abstract class Zend_Db_Table_Abstract
$whereClause = '(' . implode(' OR ', $whereOrTerms) . ')';
}
// issue ZF-5775 (empty where clause should return empty rowset)
if ($whereClause == null) {
$rowsetClass = $this->getRowsetClass();
if (!class_exists($rowsetClass)) {
require_once 'Zend/Loader.php';
Zend_Loader::loadClass($rowsetClass);
}
return new $rowsetClass(array('table' => $this, 'rowClass' => $this->getRowClass(), 'stored' => true));
}
return $this->fetchAll($whereClause);
}
@ -1307,15 +1328,16 @@ abstract class Zend_Db_Table_Abstract
'table' => $this,
'data' => $rows,
'readOnly' => $select->isReadOnly(),
'rowClass' => $this->_rowClass,
'rowClass' => $this->getRowClass(),
'stored' => true
);
if (!class_exists($this->_rowsetClass)) {
$rowsetClass = $this->getRowsetClass();
if (!class_exists($rowsetClass)) {
require_once 'Zend/Loader.php';
Zend_Loader::loadClass($this->_rowsetClass);
Zend_Loader::loadClass($rowsetClass);
}
return new $this->_rowsetClass($data);
return new $rowsetClass($data);
}
/**
@ -1359,11 +1381,12 @@ abstract class Zend_Db_Table_Abstract
'stored' => true
);
if (!class_exists($this->_rowClass)) {
$rowClass = $this->getRowClass();
if (!class_exists($rowClass)) {
require_once 'Zend/Loader.php';
Zend_Loader::loadClass($this->_rowClass);
Zend_Loader::loadClass($rowClass);
}
return new $this->_rowClass($data);
return new $rowClass($data);
}
/**
@ -1421,11 +1444,12 @@ abstract class Zend_Db_Table_Abstract
'stored' => false
);
if (!class_exists($this->_rowClass)) {
$rowClass = $this->getRowClass();
if (!class_exists($rowClass)) {
require_once 'Zend/Loader.php';
Zend_Loader::loadClass($this->_rowClass);
Zend_Loader::loadClass($rowClass);
}
$row = new $this->_rowClass($config);
$row = new $rowClass($config);
$row->setFromArray($data);
return $row;
}

View File

@ -17,7 +17,7 @@
* @subpackage Table
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Definition.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: Definition.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -31,12 +31,12 @@
*/
class Zend_Db_Table_Definition
{
/**
* @var array
*/
protected $_tableConfigs = array();
/**
* __construct()
*
@ -50,7 +50,7 @@ class Zend_Db_Table_Definition
$this->setOptions($options);
}
}
/**
* setConfig()
*
@ -62,7 +62,7 @@ class Zend_Db_Table_Definition
$this->setOptions($config->toArray());
return $this;
}
/**
* setOptions()
*
@ -76,7 +76,7 @@ class Zend_Db_Table_Definition
}
return $this;
}
/**
* @param string $tableName
* @param array $tableConfig
@ -87,15 +87,15 @@ class Zend_Db_Table_Definition
// @todo logic here
$tableConfig[Zend_Db_Table::DEFINITION_CONFIG_NAME] = $tableName;
$tableConfig[Zend_Db_Table::DEFINITION] = $this;
if (!isset($tableConfig[Zend_Db_Table::NAME])) {
$tableConfig[Zend_Db_Table::NAME] = $tableName;
}
$this->_tableConfigs[$tableName] = $tableConfig;
return $this;
}
/**
* getTableConfig()
*
@ -106,7 +106,7 @@ class Zend_Db_Table_Definition
{
return $this->_tableConfigs[$tableName];
}
/**
* removeTableConfig()
*
@ -116,7 +116,7 @@ class Zend_Db_Table_Definition
{
unset($this->_tableConfigs[$tableName]);
}
/**
* hasTableConfig()
*

View File

@ -17,7 +17,7 @@
* @subpackage Table
* @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: Abstract.php 16971 2009-07-22 18:05:45Z mikaelkael $
* @version $Id: Abstract.php 18951 2009-11-12 16:26:19Z alexander $
*/
/**
@ -472,9 +472,9 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
if (is_array($primaryKey)) {
$newPrimaryKey = $primaryKey;
} else {
//ZF-6167 Use tempPrimaryKey temporary to avoid that zend encoding fails.
//ZF-6167 Use tempPrimaryKey temporary to avoid that zend encoding fails.
$tempPrimaryKey = (array) $this->_primary;
$newPrimaryKey = array(current($tempPrimaryKey) => $primaryKey);
$newPrimaryKey = array(current($tempPrimaryKey) => $primaryKey);
}
/**
@ -865,7 +865,7 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
if (is_string($dependentTable)) {
$dependentTable = $this->_getTableFromString($dependentTable);
}
if (!$dependentTable instanceof Zend_Db_Table_Abstract) {
$type = gettype($dependentTable);
if ($type == 'object') {
@ -921,7 +921,7 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
if (is_string($parentTable)) {
$parentTable = $this->_getTableFromString($parentTable);
}
if (!$parentTable instanceof Zend_Db_Table_Abstract) {
$type = gettype($parentTable);
if ($type == 'object') {
@ -937,7 +937,7 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
&& ($parentTable->getDefinition() == null)) {
$parentTable->setOptions(array(Zend_Db_Table_Abstract::DEFINITION => $tableDefinition));
}
if ($select === null) {
$select = $parentTable->select();
} else {
@ -955,7 +955,7 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
$parentColumnName = $parentDb->foldCase($map[Zend_Db_Table_Abstract::REF_COLUMNS][$i]);
$parentColumn = $parentDb->quoteIdentifier($parentColumnName, true);
$parentInfo = $parentTable->info();
// determine where part
$type = $parentInfo[Zend_Db_Table_Abstract::METADATA][$parentColumnName]['DATA_TYPE'];
$nullable = $parentInfo[Zend_Db_Table_Abstract::METADATA][$parentColumnName]['NULLABLE'];
@ -966,7 +966,7 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
} else {
$select->where("$parentColumn = ?", $value, $type);
}
}
return $parentTable->fetchRow($select);
@ -989,7 +989,7 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
if (is_string($intersectionTable)) {
$intersectionTable = $this->_getTableFromString($intersectionTable);
}
if (!$intersectionTable instanceof Zend_Db_Table_Abstract) {
$type = gettype($intersectionTable);
if ($type == 'object') {
@ -1005,11 +1005,11 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
&& ($intersectionTable->getDefinition() == null)) {
$intersectionTable->setOptions(array(Zend_Db_Table_Abstract::DEFINITION => $tableDefinition));
}
if (is_string($matchTable)) {
$matchTable = $this->_getTableFromString($matchTable);
}
if (! $matchTable instanceof Zend_Db_Table_Abstract) {
$type = gettype($matchTable);
if ($type == 'object') {
@ -1025,7 +1025,7 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
&& ($matchTable->getDefinition() == null)) {
$matchTable->setOptions(array(Zend_Db_Table_Abstract::DEFINITION => $tableDefinition));
}
if ($select === null) {
$select = $matchTable->select();
} else {
@ -1164,12 +1164,12 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
if ($this->_table instanceof Zend_Db_Table_Abstract) {
$tableDefinition = $this->_table->getDefinition();
if ($tableDefinition !== null && $tableDefinition->hasTableConfig($tableName)) {
return new Zend_Db_Table($tableName, $tableDefinition);
}
}
}
// assume the tableName is the class name
if (!class_exists($tableName)) {
try {
@ -1182,11 +1182,11 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
}
$options = array();
if (($table = $this->_getTable())) {
$options['db'] = $table->getAdapter();
}
if (isset($tableDefinition) && $tableDefinition !== null) {
$options[Zend_Db_Table_Abstract::DEFINITION] = $tableDefinition;
}

View File

@ -18,7 +18,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 18951 2009-11-12 16:26:19Z alexander $
*/
@ -193,23 +193,27 @@ class Zend_Db_Table_Select extends Zend_Db_Select
$primary = $this->_info[Zend_Db_Table_Abstract::NAME];
$schema = $this->_info[Zend_Db_Table_Abstract::SCHEMA];
// If no fields are specified we assume all fields from primary table
if (!count($fields)) {
$this->from($primary, self::SQL_WILDCARD, $schema);
$fields = $this->getPart(Zend_Db_Table_Select::COLUMNS);
}
$from = $this->getPart(Zend_Db_Table_Select::FROM);
if (count($this->_parts[self::UNION]) == 0) {
if ($this->_integrityCheck !== false) {
foreach ($fields as $columnEntry) {
list($table, $column) = $columnEntry;
// If no fields are specified we assume all fields from primary table
if (!count($fields)) {
$this->from($primary, self::SQL_WILDCARD, $schema);
$fields = $this->getPart(Zend_Db_Table_Select::COLUMNS);
}
// Check each column to ensure it only references the primary table
if ($column) {
if (!isset($from[$table]) || $from[$table]['tableName'] != $primary) {
require_once 'Zend/Db/Table/Select/Exception.php';
throw new Zend_Db_Table_Select_Exception('Select query cannot join with another table');
$from = $this->getPart(Zend_Db_Table_Select::FROM);
if ($this->_integrityCheck !== false) {
foreach ($fields as $columnEntry) {
list($table, $column) = $columnEntry;
// Check each column to ensure it only references the primary table
if ($column) {
if (!isset($from[$table]) || $from[$table]['tableName'] != $primary) {
require_once 'Zend/Db/Table/Select/Exception.php';
throw new Zend_Db_Table_Select_Exception('Select query cannot join with another table');
}
}
}
}