import v1.1.0_RC2 | 2009-09-20
This commit is contained in:
@ -15,9 +15,9 @@
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @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 16029 2009-06-12 18:01:37Z doctorrock83 $
|
||||
* @version $Id: Abstract.php 17702 2009-08-20 23:54:16Z yoshida@zend.co.jp $
|
||||
*/
|
||||
|
||||
|
||||
@ -37,7 +37,7 @@ require_once 'Zend/Db/Select.php';
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
abstract class Zend_Db_Adapter_Abstract
|
||||
@ -210,6 +210,10 @@ abstract class Zend_Db_Adapter_Abstract
|
||||
$config['charset'] = null;
|
||||
}
|
||||
|
||||
if (!isset($config['persistent'])) {
|
||||
$config['persistent'] = false;
|
||||
}
|
||||
|
||||
$this->_config = array_merge($this->_config, $config);
|
||||
$this->_config['options'] = $options;
|
||||
$this->_config['driver_options'] = $driverOptions;
|
||||
@ -471,7 +475,7 @@ abstract class Zend_Db_Adapter_Abstract
|
||||
/**
|
||||
* Leave autocommit mode and begin a transaction.
|
||||
*
|
||||
* @return bool True
|
||||
* @return Zend_Db_Adapter_Abstract
|
||||
*/
|
||||
public function beginTransaction()
|
||||
{
|
||||
@ -479,13 +483,13 @@ abstract class Zend_Db_Adapter_Abstract
|
||||
$q = $this->_profiler->queryStart('begin', Zend_Db_Profiler::TRANSACTION);
|
||||
$this->_beginTransaction();
|
||||
$this->_profiler->queryEnd($q);
|
||||
return true;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Commit a transaction and return to autocommit mode.
|
||||
*
|
||||
* @return bool True
|
||||
* @return Zend_Db_Adapter_Abstract
|
||||
*/
|
||||
public function commit()
|
||||
{
|
||||
@ -493,13 +497,13 @@ abstract class Zend_Db_Adapter_Abstract
|
||||
$q = $this->_profiler->queryStart('commit', Zend_Db_Profiler::TRANSACTION);
|
||||
$this->_commit();
|
||||
$this->_profiler->queryEnd($q);
|
||||
return true;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Roll back a transaction and return to autocommit mode.
|
||||
*
|
||||
* @return bool True
|
||||
* @return Zend_Db_Adapter_Abstract
|
||||
*/
|
||||
public function rollBack()
|
||||
{
|
||||
@ -507,7 +511,7 @@ abstract class Zend_Db_Adapter_Abstract
|
||||
$q = $this->_profiler->queryStart('rollback', Zend_Db_Profiler::TRANSACTION);
|
||||
$this->_rollBack();
|
||||
$this->_profiler->queryEnd($q);
|
||||
return true;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -734,7 +738,7 @@ abstract class Zend_Db_Adapter_Abstract
|
||||
*
|
||||
* @param string|Zend_Db_Select $sql An SQL SELECT statement.
|
||||
* @param mixed $bind Data to bind into SELECT placeholders.
|
||||
* @return string
|
||||
* @return array
|
||||
*/
|
||||
public function fetchAssoc($sql, $bind = array())
|
||||
{
|
||||
@ -771,7 +775,7 @@ abstract class Zend_Db_Adapter_Abstract
|
||||
*
|
||||
* @param string|Zend_Db_Select $sql An SQL SELECT statement.
|
||||
* @param mixed $bind Data to bind into SELECT placeholders.
|
||||
* @return string
|
||||
* @return array
|
||||
*/
|
||||
public function fetchPairs($sql, $bind = array())
|
||||
{
|
||||
|
@ -12,10 +12,12 @@
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @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 $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -37,7 +39,7 @@ require_once 'Zend/Db/Statement/Db2.php';
|
||||
|
||||
/**
|
||||
* @package Zend_Db
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
|
@ -12,10 +12,12 @@
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @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 $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -28,7 +30,7 @@ require_once 'Zend/Db/Adapter/Exception.php';
|
||||
*
|
||||
* @package Zend_Db
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Db_Adapter_Db2_Exception extends Zend_Db_Adapter_Exception
|
||||
|
@ -15,8 +15,9 @@
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @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 $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -28,7 +29,7 @@ require_once 'Zend/Db/Exception.php';
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Db_Adapter_Exception extends Zend_Db_Exception
|
||||
|
@ -15,9 +15,9 @@
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @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 15599 2009-05-16 01:30:48Z yoshida@zend.co.jp $
|
||||
* @version $Id: Mysqli.php 16203 2009-06-21 18:56:17Z thomas $
|
||||
*/
|
||||
|
||||
|
||||
@ -46,7 +46,7 @@ require_once 'Zend/Db/Statement/Mysqli.php';
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Db_Adapter_Mysqli extends Zend_Db_Adapter_Abstract
|
||||
|
@ -15,8 +15,9 @@
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @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 $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -31,7 +32,7 @@ require_once 'Zend/Db/Adapter/Exception.php';
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Db_Adapter_Mysqli_Exception extends Zend_Db_Adapter_Exception
|
||||
|
@ -15,8 +15,9 @@
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @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 $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -33,7 +34,7 @@ require_once 'Zend/Db/Statement/Oracle.php';
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Db_Adapter_Oracle extends Zend_Db_Adapter_Abstract
|
||||
@ -47,13 +48,14 @@ class Zend_Db_Adapter_Oracle extends Zend_Db_Adapter_Abstract
|
||||
* password => (string) Password associated with the username.
|
||||
* dbname => Either the name of the local Oracle instance, or the
|
||||
* name of the entry in tnsnames.ora to which you want to connect.
|
||||
*
|
||||
* persistent => (boolean) Set TRUE to use a persistent connection
|
||||
* @var array
|
||||
*/
|
||||
protected $_config = array(
|
||||
'dbname' => null,
|
||||
'username' => null,
|
||||
'password' => null,
|
||||
'persistent' => false
|
||||
);
|
||||
|
||||
/**
|
||||
@ -117,7 +119,9 @@ 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->_connection = @oci_connect(
|
||||
$connectionFuncName = ($this->_config['persistent'] == true) ? 'oci_pconnect' : 'oci_connect';
|
||||
|
||||
$this->_connection = @$connectionFuncName(
|
||||
$this->_config['username'],
|
||||
$this->_config['password'],
|
||||
$this->_config['dbname'],
|
||||
|
@ -15,8 +15,9 @@
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @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 $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -30,7 +31,7 @@ require_once 'Zend/Db/Adapter/Exception.php';
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Db_Adapter_Oracle_Exception extends Zend_Db_Adapter_Exception
|
||||
|
@ -15,9 +15,9 @@
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @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 15577 2009-05-14 12:43:34Z matthew $
|
||||
* @version $Id: Abstract.php 16920 2009-07-21 13:32:28Z ralph $
|
||||
*/
|
||||
|
||||
|
||||
@ -39,7 +39,7 @@ require_once 'Zend/Db/Statement/Pdo.php';
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
abstract class Zend_Db_Adapter_Pdo_Abstract extends Zend_Db_Adapter_Abstract
|
||||
@ -62,11 +62,12 @@ abstract class Zend_Db_Adapter_Pdo_Abstract extends Zend_Db_Adapter_Abstract
|
||||
// baseline of DSN parts
|
||||
$dsn = $this->_config;
|
||||
|
||||
// don't pass the username, password, and driver_options in the DSN
|
||||
// don't pass the username, password, charset, persistent and driver_options in the DSN
|
||||
unset($dsn['username']);
|
||||
unset($dsn['password']);
|
||||
unset($dsn['options']);
|
||||
unset($dsn['charset']);
|
||||
unset($dsn['persistent']);
|
||||
unset($dsn['driver_options']);
|
||||
|
||||
// use all remaining parts in the DSN
|
||||
@ -114,6 +115,11 @@ abstract class Zend_Db_Adapter_Pdo_Abstract extends Zend_Db_Adapter_Abstract
|
||||
// create PDO connection
|
||||
$q = $this->_profiler->queryStart('connect', Zend_Db_Profiler::CONNECT);
|
||||
|
||||
// add the persistence flag if we find it in our config array
|
||||
if (isset($this->_config['persistent']) && ($this->_config['persistent'] == true)) {
|
||||
$this->_config['driver_options'][PDO::ATTR_PERSISTENT] = true;
|
||||
}
|
||||
|
||||
try {
|
||||
$this->_connection = new PDO(
|
||||
$dsn,
|
||||
|
@ -15,9 +15,9 @@
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @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 13522 2009-01-06 16:35:55Z thomas $
|
||||
* @version $Id: Ibm.php 16203 2009-06-21 18:56:17Z thomas $
|
||||
*/
|
||||
|
||||
|
||||
@ -38,7 +38,7 @@ require_once 'Zend/Db/Statement/Pdo/Ibm.php';
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Db_Adapter_Pdo_Ibm extends Zend_Db_Adapter_Pdo_Abstract
|
||||
|
@ -15,9 +15,9 @@
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @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 9101 2008-03-30 19:54:38Z thomas $
|
||||
* @version $Id: Db2.php 16203 2009-06-21 18:56:17Z thomas $
|
||||
*/
|
||||
|
||||
|
||||
@ -32,7 +32,7 @@ require_once 'Zend/Db/Statement/Pdo/Ibm.php';
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Db_Adapter_Pdo_Ibm_Db2
|
||||
|
@ -15,9 +15,9 @@
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @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: $
|
||||
* @version $Id: Ids.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
*/
|
||||
|
||||
|
||||
@ -32,7 +32,7 @@ require_once 'Zend/Db/Statement/Pdo/Ibm.php';
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Db_Adapter_Pdo_Ibm_Ids
|
||||
|
@ -15,9 +15,9 @@
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @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 12960 2008-11-30 11:04:38Z mikaelkael $
|
||||
* @version $Id: Mssql.php 17792 2009-08-24 16:18:02Z ralph $
|
||||
*/
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@ require_once 'Zend/Db/Adapter/Pdo/Abstract.php';
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Db_Adapter_Pdo_Mssql extends Zend_Db_Adapter_Pdo_Abstract
|
||||
@ -85,6 +85,8 @@ class Zend_Db_Adapter_Pdo_Mssql extends Zend_Db_Adapter_Pdo_Abstract
|
||||
// don't pass the username and password in the DSN
|
||||
unset($dsn['username']);
|
||||
unset($dsn['password']);
|
||||
unset($dsn['options']);
|
||||
unset($dsn['persistent']);
|
||||
unset($dsn['driver_options']);
|
||||
|
||||
if (isset($dsn['port'])) {
|
||||
@ -218,10 +220,20 @@ class Zend_Db_Adapter_Pdo_Mssql extends Zend_Db_Adapter_Pdo_Abstract
|
||||
*/
|
||||
public function describeTable($tableName, $schemaName = null)
|
||||
{
|
||||
if ($schemaName != null) {
|
||||
if (strpos($schemaName, '.') !== false) {
|
||||
$result = explode('.', $schemaName);
|
||||
$schemaName = $result[1];
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Discover metadata information about this table.
|
||||
*/
|
||||
$sql = "exec sp_columns @table_name = " . $this->quoteIdentifier($tableName, true);
|
||||
if ($schemaName != null) {
|
||||
$sql .= ", @table_owner = " . $this->quoteIdentifier($schemaName, true);
|
||||
}
|
||||
|
||||
$stmt = $this->query($sql);
|
||||
$result = $stmt->fetchAll(Zend_Db::FETCH_NUM);
|
||||
|
||||
@ -239,6 +251,10 @@ class Zend_Db_Adapter_Pdo_Mssql extends Zend_Db_Adapter_Pdo_Abstract
|
||||
* Discover primary key column(s) for this table.
|
||||
*/
|
||||
$sql = "exec sp_pkeys @table_name = " . $this->quoteIdentifier($tableName, true);
|
||||
if ($schemaName != null) {
|
||||
$sql .= ", @table_owner = " . $this->quoteIdentifier($schemaName, true);
|
||||
}
|
||||
|
||||
$stmt = $this->query($sql);
|
||||
$primaryKeysResult = $stmt->fetchAll(Zend_Db::FETCH_NUM);
|
||||
$primaryKeyColumn = array();
|
||||
@ -314,25 +330,51 @@ class Zend_Db_Adapter_Pdo_Mssql extends Zend_Db_Adapter_Pdo_Abstract
|
||||
throw new Zend_Db_Adapter_Exception("LIMIT argument offset=$offset is not valid");
|
||||
}
|
||||
|
||||
$orderby = stristr($sql, 'ORDER BY');
|
||||
if ($orderby !== false) {
|
||||
$sort = (stripos($orderby, ' desc') !== false) ? 'desc' : 'asc';
|
||||
$order = str_ireplace('ORDER BY', '', $orderby);
|
||||
$order = trim(preg_replace('/\bASC\b|\bDESC\b/i', '', $order));
|
||||
$sql = preg_replace(
|
||||
'/^SELECT\s+(DISTINCT\s)?/i',
|
||||
'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;
|
||||
}
|
||||
}
|
||||
|
||||
$sql = preg_replace('/^SELECT\s/i', 'SELECT TOP ' . ($count+$offset) . ' ', $sql);
|
||||
|
||||
$sql = 'SELECT * FROM (SELECT TOP ' . $count . ' * FROM (' . $sql . ') AS inner_tbl';
|
||||
if ($orderby !== false) {
|
||||
$sql .= ' ORDER BY ' . $order . ' ';
|
||||
$sql .= (stripos($sort, 'asc') !== false) ? 'DESC' : 'ASC';
|
||||
}
|
||||
$sql .= ') AS outer_tbl';
|
||||
if ($orderby !== false) {
|
||||
$sql .= ' ORDER BY ' . $order . ' ' . $sort;
|
||||
}
|
||||
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
|
@ -15,9 +15,9 @@
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @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: Mysql.php 14953 2009-04-17 00:56:16Z norm2782 $
|
||||
* @version $Id: Mysql.php 16942 2009-07-22 04:03:09Z ralph $
|
||||
*/
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@ require_once 'Zend/Db/Adapter/Pdo/Abstract.php';
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Db_Adapter_Pdo_Mysql extends Zend_Db_Adapter_Pdo_Abstract
|
||||
@ -90,7 +90,7 @@ class Zend_Db_Adapter_Pdo_Mysql extends Zend_Db_Adapter_Pdo_Abstract
|
||||
|
||||
if (!empty($this->_config['charset'])) {
|
||||
$initCommand = "SET NAMES '" . $this->_config['charset'] . "'";
|
||||
$this->_config['driver_options'][PDO::MYSQL_ATTR_INIT_COMMAND] = $initCommand;
|
||||
$this->_config['driver_options'][1002] = $initCommand; // 1002 = PDO::MYSQL_ATTR_INIT_COMMAND
|
||||
}
|
||||
|
||||
parent::_connect();
|
||||
|
@ -15,9 +15,9 @@
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @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 14107 2009-02-18 21:58:36Z norm2782 $
|
||||
* @version $Id: Oci.php 16203 2009-06-21 18:56:17Z thomas $
|
||||
*/
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@ require_once 'Zend/Db/Adapter/Pdo/Abstract.php';
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Db_Adapter_Pdo_Oci extends Zend_Db_Adapter_Pdo_Abstract
|
||||
|
@ -15,9 +15,9 @@
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @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 14953 2009-04-17 00:56:16Z norm2782 $
|
||||
* @version $Id: Pgsql.php 16732 2009-07-15 12:44:36Z yoshida@zend.co.jp $
|
||||
*/
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@ require_once 'Zend/Db/Adapter/Pdo/Abstract.php';
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Db_Adapter_Pdo_Pgsql extends Zend_Db_Adapter_Pdo_Abstract
|
||||
@ -84,7 +84,7 @@ class Zend_Db_Adapter_Pdo_Pgsql extends Zend_Db_Adapter_Pdo_Abstract
|
||||
return;
|
||||
}
|
||||
|
||||
parent::_connect();
|
||||
parent::_connect();
|
||||
|
||||
if (!empty($this->_config['charset'])) {
|
||||
$sql = "SET NAMES '" . $this->_config['charset'] . "'";
|
||||
|
@ -15,9 +15,9 @@
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @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 9101 2008-03-30 19:54:38Z thomas $
|
||||
* @version $Id: Sqlite.php 16203 2009-06-21 18:56:17Z thomas $
|
||||
*/
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@ require_once 'Zend/Db/Adapter/Pdo/Abstract.php';
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Db_Adapter_Pdo_Sqlite extends Zend_Db_Adapter_Pdo_Abstract
|
||||
|
661
libs/Zend/Db/Adapter/Sqlsrv.php
Normal file
661
libs/Zend/Db/Adapter/Sqlsrv.php
Normal file
@ -0,0 +1,661 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @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
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Db_Adapter_Abstract
|
||||
*/
|
||||
require_once 'Zend/Db/Adapter/Abstract.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Db_Statement_Sqlsrv
|
||||
*/
|
||||
require_once 'Zend/Db/Statement/Sqlsrv.php';
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @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
|
||||
*/
|
||||
class Zend_Db_Adapter_Sqlsrv extends Zend_Db_Adapter_Abstract
|
||||
{
|
||||
/**
|
||||
* User-provided configuration.
|
||||
*
|
||||
* Basic keys are:
|
||||
*
|
||||
* username => (string) Connect to the database as this username.
|
||||
* password => (string) Password associated with the username.
|
||||
* dbname => The name of the local SQL Server instance
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_config = array(
|
||||
'dbname' => null,
|
||||
'username' => null,
|
||||
'password' => null,
|
||||
);
|
||||
|
||||
/**
|
||||
* Last insert id from INSERT query
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_lastInsertId;
|
||||
|
||||
/**
|
||||
* Query used to fetch last insert id
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_lastInsertSQL = 'SELECT SCOPE_IDENTITY() as Current_Identity';
|
||||
|
||||
/**
|
||||
* Keys are UPPERCASE SQL datatypes or the constants
|
||||
* Zend_Db::INT_TYPE, Zend_Db::BIGINT_TYPE, or Zend_Db::FLOAT_TYPE.
|
||||
*
|
||||
* Values are:
|
||||
* 0 = 32-bit integer
|
||||
* 1 = 64-bit integer
|
||||
* 2 = float or decimal
|
||||
*
|
||||
* @var array Associative array of datatypes to values 0, 1, or 2.
|
||||
*/
|
||||
protected $_numericDataTypes = array(
|
||||
Zend_Db::INT_TYPE => Zend_Db::INT_TYPE,
|
||||
Zend_Db::BIGINT_TYPE => Zend_Db::BIGINT_TYPE,
|
||||
Zend_Db::FLOAT_TYPE => Zend_Db::FLOAT_TYPE,
|
||||
'INT' => Zend_Db::INT_TYPE,
|
||||
'SMALLINT' => Zend_Db::INT_TYPE,
|
||||
'TINYINT' => Zend_Db::INT_TYPE,
|
||||
'BIGINT' => Zend_Db::BIGINT_TYPE,
|
||||
'DECIMAL' => Zend_Db::FLOAT_TYPE,
|
||||
'FLOAT' => Zend_Db::FLOAT_TYPE,
|
||||
'MONEY' => Zend_Db::FLOAT_TYPE,
|
||||
'NUMERIC' => Zend_Db::FLOAT_TYPE,
|
||||
'REAL' => Zend_Db::FLOAT_TYPE,
|
||||
'SMALLMONEY' => Zend_Db::FLOAT_TYPE,
|
||||
);
|
||||
|
||||
/**
|
||||
* Default class name for a DB statement.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_defaultStmtClass = 'Zend_Db_Statement_Sqlsrv';
|
||||
|
||||
/**
|
||||
* Creates a connection resource.
|
||||
*
|
||||
* @return void
|
||||
* @throws Zend_Db_Adapter_Sqlsrv_Exception
|
||||
*/
|
||||
protected function _connect()
|
||||
{
|
||||
if (is_resource($this->_connection)) {
|
||||
// connection already exists
|
||||
return;
|
||||
}
|
||||
|
||||
if (!extension_loaded('sqlsrv')) {
|
||||
/**
|
||||
* @see Zend_Db_Adapter_Sqlsrv_Exception
|
||||
*/
|
||||
require_once 'Zend/Db/Adapter/Sqlsrv/Exception.php';
|
||||
throw new Zend_Db_Adapter_Sqlsrv_Exception('The Sqlsrv extension is required for this adapter but the extension is not loaded');
|
||||
}
|
||||
|
||||
$serverName = $this->_config['host'];
|
||||
if (isset($this->_config['port'])) {
|
||||
$port = (integer) $this->_config['port'];
|
||||
$serverName .= ', ' . $port;
|
||||
}
|
||||
|
||||
$connectionInfo = array(
|
||||
'Database' => $this->_config['dbname'],
|
||||
);
|
||||
|
||||
if (isset($this->_config['username']) && isset($this->_config['password']))
|
||||
{
|
||||
$connectionInfo += array(
|
||||
'UID' => $this->_config['username'],
|
||||
'PWD' => $this->_config['password'],
|
||||
);
|
||||
}
|
||||
// else - windows authentication
|
||||
|
||||
if (!empty($this->_config['driver_options'])) {
|
||||
foreach ($this->_config['driver_options'] as $option => $value) {
|
||||
// A value may be a constant.
|
||||
if (is_string($value)) {
|
||||
$constantValue = @constant(strtoupper($value));
|
||||
if ($constantValue === null) {
|
||||
$connectionInfo[$option] = $value;
|
||||
} else {
|
||||
$connectionInfo[$option] = $constantValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->_connection = sqlsrv_connect($serverName, $connectionInfo);
|
||||
|
||||
if (!$this->_connection) {
|
||||
/**
|
||||
* @see Zend_Db_Adapter_Sqlsrv_Exception
|
||||
*/
|
||||
require_once 'Zend/Db/Adapter/Sqlsrv/Exception.php';
|
||||
throw new Zend_Db_Adapter_Sqlsrv_Exception(sqlsrv_errors());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for config options that are mandatory.
|
||||
* Throw exceptions if any are missing.
|
||||
*
|
||||
* @param array $config
|
||||
* @throws Zend_Db_Adapter_Exception
|
||||
*/
|
||||
protected function _checkRequiredOptions(array $config)
|
||||
{
|
||||
// we need at least a dbname
|
||||
if (! array_key_exists('dbname', $config)) {
|
||||
/** @see Zend_Db_Adapter_Exception */
|
||||
require_once 'Zend/Db/Adapter/Exception.php';
|
||||
throw new Zend_Db_Adapter_Exception("Configuration array must have a key for 'dbname' that names the database instance");
|
||||
}
|
||||
|
||||
if (! array_key_exists('password', $config) && array_key_exists('username', $config)) {
|
||||
/**
|
||||
* @see Zend_Db_Adapter_Exception
|
||||
*/
|
||||
require_once 'Zend/Db/Adapter/Exception.php';
|
||||
throw new Zend_Db_Adapter_Exception("Configuration array must have a key for 'password' for login credentials.
|
||||
If Windows Authentication is desired, both keys 'username' and 'password' should be ommited from config.");
|
||||
}
|
||||
|
||||
if (array_key_exists('password', $config) && !array_key_exists('username', $config)) {
|
||||
/**
|
||||
* @see Zend_Db_Adapter_Exception
|
||||
*/
|
||||
require_once 'Zend/Db/Adapter/Exception.php';
|
||||
throw new Zend_Db_Adapter_Exception("Configuration array must have a key for 'username' for login credentials.
|
||||
If Windows Authentication is desired, both keys 'username' and 'password' should be ommited from config.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the transaction isoltion level.
|
||||
*
|
||||
* @param integer|null $level A fetch mode from SQLSRV_TXN_*.
|
||||
* @return true
|
||||
* @throws Zend_Db_Adapter_Sqlsrv_Exception
|
||||
*/
|
||||
public function setTransactionIsolationLevel($level = null)
|
||||
{
|
||||
$this->_connect();
|
||||
$sql = null;
|
||||
|
||||
// Default transaction level in sql server
|
||||
if ($level === null)
|
||||
{
|
||||
$level = SQLSRV_TXN_READ_COMMITTED;
|
||||
}
|
||||
|
||||
switch ($level) {
|
||||
case SQLSRV_TXN_READ_UNCOMMITTED:
|
||||
$sql = "READ UNCOMMITTED";
|
||||
break;
|
||||
case SQLSRV_TXN_READ_COMMITTED:
|
||||
$sql = "READ COMMITTED";
|
||||
break;
|
||||
case SQLSRV_TXN_REPEATABLE_READ:
|
||||
$sql = "REPEATABLE READ";
|
||||
break;
|
||||
case SQLSRV_TXN_SNAPSHOT:
|
||||
$sql = "SNAPSHOT";
|
||||
break;
|
||||
case SQLSRV_TXN_SERIALIZABLE:
|
||||
$sql = "SERIALIZABLE";
|
||||
break;
|
||||
default:
|
||||
require_once 'Zend/Db/Adapter/Sqlsrv/Exception.php';
|
||||
throw new Zend_Db_Adapter_Sqlsrv_Exception("Invalid transaction isolation level mode '$level' specified");
|
||||
}
|
||||
|
||||
if (!sqlsrv_query($this->_connection, "SET TRANSACTION ISOLATION LEVEL $sql;")) {
|
||||
require_once 'Zend/Db/Adapter/Sqlsrv/Exception.php';
|
||||
throw new Zend_Db_Adapter_Sqlsrv_Exception("Transaction cannot be changed to '$level'");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if a connection is active
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isConnected()
|
||||
{
|
||||
return (is_resource($this->_connection)
|
||||
&& (get_resource_type($this->_connection) == 'SQL Server Connection')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Force the connection to close.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function closeConnection()
|
||||
{
|
||||
if ($this->isConnected()) {
|
||||
sqlsrv_close($this->_connection);
|
||||
}
|
||||
$this->_connection = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an SQL statement for preparation.
|
||||
*
|
||||
* @param string $sql The SQL statement with placeholders.
|
||||
* @return Zend_Db_Statement_Sqlsrv
|
||||
*/
|
||||
public function prepare($sql)
|
||||
{
|
||||
$this->_connect();
|
||||
$stmtClass = $this->_defaultStmtClass;
|
||||
|
||||
if (!class_exists($stmtClass)) {
|
||||
/**
|
||||
* @see Zend_Loader
|
||||
*/
|
||||
require_once 'Zend/Loader.php';
|
||||
Zend_Loader::loadClass($stmtClass);
|
||||
}
|
||||
|
||||
$stmt = new $stmtClass($this, $sql);
|
||||
$stmt->setFetchMode($this->_fetchMode);
|
||||
return $stmt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Quote a raw string.
|
||||
*
|
||||
* @param string $value Raw string
|
||||
* @return string Quoted string
|
||||
*/
|
||||
protected function _quote($value)
|
||||
{
|
||||
if (is_int($value)) {
|
||||
return $value;
|
||||
} elseif (is_float($value)) {
|
||||
return sprintf('%F', $value);
|
||||
}
|
||||
|
||||
return "'" . str_replace("'", "''", $value) . "'";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the last ID generated automatically by an IDENTITY/AUTOINCREMENT column.
|
||||
*
|
||||
* As a convention, on RDBMS brands that support sequences
|
||||
* (e.g. Oracle, PostgreSQL, DB2), this method forms the name of a sequence
|
||||
* from the arguments and returns the last id generated by that sequence.
|
||||
* On RDBMS brands that support IDENTITY/AUTOINCREMENT columns, this method
|
||||
* returns the last value generated for such a column, and the table name
|
||||
* argument is disregarded.
|
||||
*
|
||||
* @param string $tableName OPTIONAL Name of table.
|
||||
* @param string $primaryKey OPTIONAL Name of primary key column.
|
||||
* @return string
|
||||
*/
|
||||
public function lastInsertId($tableName = null, $primaryKey = null)
|
||||
{
|
||||
if ($tableName) {
|
||||
$tableName = $this->quote($tableName);
|
||||
$sql = 'SELECT IDENT_CURRENT (' . $tableName . ') as Current_Identity';
|
||||
return (string) $this->fetchOne($sql);
|
||||
}
|
||||
|
||||
if ($this->_lastInsertId > 0) {
|
||||
return (string) $this->_lastInsertId;
|
||||
}
|
||||
|
||||
$sql = $this->_lastInsertSQL;
|
||||
return (string) $this->fetchOne($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts a table row with specified data.
|
||||
*
|
||||
* @param mixed $table The table to insert data into.
|
||||
* @param array $bind Column-value pairs.
|
||||
* @return int The number of affected rows.
|
||||
*/
|
||||
public function insert($table, array $bind)
|
||||
{
|
||||
// extract and quote col names from the array keys
|
||||
$cols = array();
|
||||
$vals = array();
|
||||
foreach ($bind as $col => $val) {
|
||||
$cols[] = $this->quoteIdentifier($col, true);
|
||||
if ($val instanceof Zend_Db_Expr) {
|
||||
$vals[] = $val->__toString();
|
||||
unset($bind[$col]);
|
||||
} else {
|
||||
$vals[] = '?';
|
||||
}
|
||||
}
|
||||
|
||||
// build the statement
|
||||
$sql = "INSERT INTO "
|
||||
. $this->quoteIdentifier($table, true)
|
||||
. ' (' . implode(', ', $cols) . ') '
|
||||
. 'VALUES (' . implode(', ', $vals) . ')'
|
||||
. ' ' . $this->_lastInsertSQL;
|
||||
|
||||
// execute the statement and return the number of affected rows
|
||||
$stmt = $this->query($sql, array_values($bind));
|
||||
$result = $stmt->rowCount();
|
||||
|
||||
$stmt->nextRowset();
|
||||
|
||||
$this->_lastInsertId = $stmt->fetchColumn();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of the tables in the database.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function listTables()
|
||||
{
|
||||
$this->_connect();
|
||||
$sql = "SELECT name FROM sysobjects WHERE type = 'U' ORDER BY name";
|
||||
return $this->fetchCol($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the column descriptions for a table.
|
||||
*
|
||||
* The return value is an associative array keyed by the column name,
|
||||
* as returned by the RDBMS.
|
||||
*
|
||||
* The value of each array element is an associative array
|
||||
* with the following keys:
|
||||
*
|
||||
* SCHEMA_NAME => string; name of schema
|
||||
* TABLE_NAME => string;
|
||||
* COLUMN_NAME => string; column name
|
||||
* COLUMN_POSITION => number; ordinal position of column in table
|
||||
* DATA_TYPE => string; SQL datatype name of column
|
||||
* DEFAULT => string; default expression of column, null if none
|
||||
* NULLABLE => boolean; true if column can have nulls
|
||||
* LENGTH => number; length of CHAR/VARCHAR
|
||||
* SCALE => number; scale of NUMERIC/DECIMAL
|
||||
* PRECISION => number; precision of NUMERIC/DECIMAL
|
||||
* UNSIGNED => boolean; unsigned property of an integer type
|
||||
* PRIMARY => boolean; true if column is part of the primary key
|
||||
* PRIMARY_POSITION => integer; position of column in primary key
|
||||
* IDENTITY => integer; true if column is auto-generated with unique values
|
||||
*
|
||||
* @todo Discover integer unsigned property.
|
||||
*
|
||||
* @param string $tableName
|
||||
* @param string $schemaName OPTIONAL
|
||||
* @return array
|
||||
*/
|
||||
public function describeTable($tableName, $schemaName = null)
|
||||
{
|
||||
/**
|
||||
* Discover metadata information about this table.
|
||||
*/
|
||||
$sql = "exec sp_columns @table_name = " . $this->quoteIdentifier($tableName, true);
|
||||
$stmt = $this->query($sql);
|
||||
$result = $stmt->fetchAll(Zend_Db::FETCH_NUM);
|
||||
|
||||
$owner = 1;
|
||||
$table_name = 2;
|
||||
$column_name = 3;
|
||||
$type_name = 5;
|
||||
$precision = 6;
|
||||
$length = 7;
|
||||
$scale = 8;
|
||||
$nullable = 10;
|
||||
$column_def = 12;
|
||||
$column_position = 16;
|
||||
|
||||
/**
|
||||
* Discover primary key column(s) for this table.
|
||||
*/
|
||||
$tableOwner = $result[0][$owner];
|
||||
$sql = "exec sp_pkeys @table_owner = " . $tableOwner
|
||||
. ", @table_name = " . $this->quoteIdentifier($tableName, true);
|
||||
$stmt = $this->query($sql);
|
||||
|
||||
$primaryKeysResult = $stmt->fetchAll(Zend_Db::FETCH_NUM);
|
||||
$primaryKeyColumn = array();
|
||||
|
||||
// Per http://msdn.microsoft.com/en-us/library/ms189813.aspx,
|
||||
// results from sp_keys stored procedure are:
|
||||
// 0=TABLE_QUALIFIER 1=TABLE_OWNER 2=TABLE_NAME 3=COLUMN_NAME 4=KEY_SEQ 5=PK_NAME
|
||||
|
||||
$pkey_column_name = 3;
|
||||
$pkey_key_seq = 4;
|
||||
foreach ($primaryKeysResult as $pkeysRow) {
|
||||
$primaryKeyColumn[$pkeysRow[$pkey_column_name]] = $pkeysRow[$pkey_key_seq];
|
||||
}
|
||||
|
||||
$desc = array();
|
||||
$p = 1;
|
||||
foreach ($result as $key => $row) {
|
||||
$identity = false;
|
||||
$words = explode(' ', $row[$type_name], 2);
|
||||
if (isset($words[0])) {
|
||||
$type = $words[0];
|
||||
if (isset($words[1])) {
|
||||
$identity = (bool) preg_match('/identity/', $words[1]);
|
||||
}
|
||||
}
|
||||
|
||||
$isPrimary = array_key_exists($row[$column_name], $primaryKeyColumn);
|
||||
if ($isPrimary) {
|
||||
$primaryPosition = $primaryKeyColumn[$row[$column_name]];
|
||||
} else {
|
||||
$primaryPosition = null;
|
||||
}
|
||||
|
||||
$desc[$this->foldCase($row[$column_name])] = array(
|
||||
'SCHEMA_NAME' => null, // @todo
|
||||
'TABLE_NAME' => $this->foldCase($row[$table_name]),
|
||||
'COLUMN_NAME' => $this->foldCase($row[$column_name]),
|
||||
'COLUMN_POSITION' => (int) $row[$column_position],
|
||||
'DATA_TYPE' => $type,
|
||||
'DEFAULT' => $row[$column_def],
|
||||
'NULLABLE' => (bool) $row[$nullable],
|
||||
'LENGTH' => $row[$length],
|
||||
'SCALE' => $row[$scale],
|
||||
'PRECISION' => $row[$precision],
|
||||
'UNSIGNED' => null, // @todo
|
||||
'PRIMARY' => $isPrimary,
|
||||
'PRIMARY_POSITION' => $primaryPosition,
|
||||
'IDENTITY' => $identity,
|
||||
);
|
||||
}
|
||||
|
||||
return $desc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Leave autocommit mode and begin a transaction.
|
||||
*
|
||||
* @return void
|
||||
* @throws Zend_Db_Adapter_Sqlsrv_Exception
|
||||
*/
|
||||
protected function _beginTransaction()
|
||||
{
|
||||
if (!sqlsrv_begin_transaction($this->_connection)) {
|
||||
require_once 'Zend/Db/Adapter/Sqlsrv/Exception.php';
|
||||
throw new Zend_Db_Adapter_Sqlsrv_Exception(sqlsrv_errors());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Commit a transaction and return to autocommit mode.
|
||||
*
|
||||
* @return void
|
||||
* @throws Zend_Db_Adapter_Sqlsrv_Exception
|
||||
*/
|
||||
protected function _commit()
|
||||
{
|
||||
if (!sqlsrv_commit($this->_connection)) {
|
||||
require_once 'Zend/Db/Adapter/Sqlsrv/Exception.php';
|
||||
throw new Zend_Db_Adapter_Sqlsrv_Exception(sqlsrv_errors());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Roll back a transaction and return to autocommit mode.
|
||||
*
|
||||
* @return void
|
||||
* @throws Zend_Db_Adapter_Sqlsrv_Exception
|
||||
*/
|
||||
protected function _rollBack()
|
||||
{
|
||||
if (!sqlsrv_rollback($this->_connection)) {
|
||||
require_once 'Zend/Db/Adapter/Sqlsrv/Exception.php';
|
||||
throw new Zend_Db_Adapter_Sqlsrv_Exception(sqlsrv_errors());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the fetch mode.
|
||||
*
|
||||
* @todo Support FETCH_CLASS and FETCH_INTO.
|
||||
*
|
||||
* @param integer $mode A fetch mode.
|
||||
* @return void
|
||||
* @throws Zend_Db_Adapter_Sqlsrv_Exception
|
||||
*/
|
||||
public function setFetchMode($mode)
|
||||
{
|
||||
switch ($mode) {
|
||||
case Zend_Db::FETCH_NUM: // seq array
|
||||
case Zend_Db::FETCH_ASSOC: // assoc array
|
||||
case Zend_Db::FETCH_BOTH: // seq+assoc array
|
||||
case Zend_Db::FETCH_OBJ: // object
|
||||
$this->_fetchMode = $mode;
|
||||
break;
|
||||
case Zend_Db::FETCH_BOUND: // bound to PHP variable
|
||||
require_once 'Zend/Db/Adapter/Sqlsrv/Exception.php';
|
||||
throw new Zend_Db_Adapter_Sqlsrv_Exception('FETCH_BOUND is not supported yet');
|
||||
break;
|
||||
default:
|
||||
require_once 'Zend/Db/Adapter/Sqlsrv/Exception.php';
|
||||
throw new Zend_Db_Adapter_Sqlsrv_Exception("Invalid fetch mode '$mode' specified");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an adapter-specific LIMIT clause to the SELECT statement.
|
||||
*
|
||||
* @param string $sql
|
||||
* @param integer $count
|
||||
* @param integer $offset OPTIONAL
|
||||
* @return string
|
||||
* @throws Zend_Db_Adapter_Sqlsrv_Exception
|
||||
*/
|
||||
public function limit($sql, $count, $offset = 0)
|
||||
{
|
||||
$count = intval($count);
|
||||
if ($count <= 0) {
|
||||
require_once 'Zend/Db/Adapter/Exception.php';
|
||||
throw new Zend_Db_Adapter_Exception("LIMIT argument count=$count is not valid");
|
||||
}
|
||||
|
||||
$offset = intval($offset);
|
||||
if ($offset < 0) {
|
||||
/** @see Zend_Db_Adapter_Exception */
|
||||
require_once 'Zend/Db/Adapter/Exception.php';
|
||||
throw new Zend_Db_Adapter_Exception("LIMIT argument offset=$offset is not valid");
|
||||
}
|
||||
|
||||
$orderby = stristr($sql, 'ORDER BY');
|
||||
if ($orderby !== false) {
|
||||
$sort = (stripos($orderby, ' desc') !== false) ? 'desc' : 'asc';
|
||||
$order = str_ireplace('ORDER BY', '', $orderby);
|
||||
$order = trim(preg_replace('/\bASC\b|\bDESC\b/i', '', $order));
|
||||
}
|
||||
|
||||
$sql = preg_replace('/^SELECT\s/i', 'SELECT TOP ' . ($count+$offset) . ' ', $sql);
|
||||
|
||||
$sql = 'SELECT * FROM (SELECT TOP ' . $count . ' * FROM (' . $sql . ') AS inner_tbl';
|
||||
if ($orderby !== false) {
|
||||
$sql .= ' ORDER BY ' . $order . ' ';
|
||||
$sql .= (stripos($sort, 'asc') !== false) ? 'DESC' : 'ASC';
|
||||
}
|
||||
$sql .= ') AS outer_tbl';
|
||||
if ($orderby !== false) {
|
||||
$sql .= ' ORDER BY ' . $order . ' ' . $sort;
|
||||
}
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the adapter supports real SQL parameters.
|
||||
*
|
||||
* @param string $type 'positional' or 'named'
|
||||
* @return bool
|
||||
*/
|
||||
public function supportsParameters($type)
|
||||
{
|
||||
if ($type == 'positional') {
|
||||
return true;
|
||||
}
|
||||
|
||||
// if its 'named' or anything else
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve server version in PHP style
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getServerVersion()
|
||||
{
|
||||
$this->_connect();
|
||||
$version = sqlsrv_client_info($this->_connection);
|
||||
|
||||
if ($version !== false) {
|
||||
return $version['DriverVer'];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
63
libs/Zend/Db/Adapter/Sqlsrv/Exception.php
Normal file
63
libs/Zend/Db/Adapter/Sqlsrv/Exception.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @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
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Db_Adapter_Exception
|
||||
*/
|
||||
require_once 'Zend/Db/Adapter/Exception.php';
|
||||
|
||||
/**
|
||||
* Zend_Db_Adapter_Sqlsrv_Exception
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @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
|
||||
*/
|
||||
class Zend_Db_Adapter_Sqlsrv_Exception extends Zend_Db_Adapter_Exception
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* If $message is an array, the assumption is that the return value of
|
||||
* sqlsrv_errors() was provided. If so, it then retrieves the most recent
|
||||
* error from that stack, and sets the message and code based on it.
|
||||
*
|
||||
* @param null|array|string $message
|
||||
* @param null|int $code
|
||||
*/
|
||||
public function __construct($message = null, $code = 0)
|
||||
{
|
||||
if (is_array($message)) {
|
||||
// Error should be array of errors
|
||||
// We only need first one (?)
|
||||
if (isset($message[0])) {
|
||||
$message = $message[0];
|
||||
}
|
||||
|
||||
$code = (int) $message['code'];
|
||||
$message = (string) $message['message'];
|
||||
}
|
||||
parent::__construct($message, new Exception($message, $code));
|
||||
}
|
||||
}
|
@ -14,8 +14,9 @@
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @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 $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -26,7 +27,7 @@ require_once 'Zend/Exception.php';
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Db_Exception extends Zend_Exception
|
||||
|
@ -15,9 +15,9 @@
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Expr
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @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: Expr.php 9101 2008-03-30 19:54:38Z thomas $
|
||||
* @version $Id: Expr.php 16203 2009-06-21 18:56:17Z thomas $
|
||||
*/
|
||||
|
||||
|
||||
@ -43,7 +43,7 @@
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Expr
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Db_Expr
|
||||
|
@ -15,9 +15,9 @@
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Profiler
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @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: Profiler.php 15403 2009-05-08 12:13:49Z yoshida@zend.co.jp $
|
||||
* @version $Id: Profiler.php 16203 2009-06-21 18:56:17Z thomas $
|
||||
*/
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Profiler
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Db_Profiler
|
||||
|
@ -15,9 +15,9 @@
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Profiler
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @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 9101 2008-03-30 19:54:38Z thomas $
|
||||
* @version $Id: Exception.php 16203 2009-06-21 18:56:17Z thomas $
|
||||
*/
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@ require_once 'Zend/Db/Exception.php';
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Profiler
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Db_Profiler_Exception extends Zend_Db_Exception
|
||||
|
@ -15,8 +15,9 @@
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Profiler
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @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 $
|
||||
*/
|
||||
|
||||
/** Zend_Db_Profiler */
|
||||
@ -34,7 +35,7 @@ require_once 'Zend/Wildfire/Plugin/FirePhp/TableMessage.php';
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Profiler
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Db_Profiler_Firebug extends Zend_Db_Profiler
|
||||
|
@ -15,9 +15,9 @@
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Profiler
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @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: Query.php 9101 2008-03-30 19:54:38Z thomas $
|
||||
* @version $Id: Query.php 16203 2009-06-21 18:56:17Z thomas $
|
||||
*/
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Profiler
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Db_Profiler_Query
|
||||
|
@ -15,9 +15,9 @@
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Select
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @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 6897 2007-11-22 08:31:59Z thomas $
|
||||
* @version $Id: Select.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
*/
|
||||
|
||||
|
||||
@ -38,7 +38,7 @@ require_once 'Zend/Db/Expr.php';
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Select
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Db_Select
|
||||
@ -682,7 +682,7 @@ class Zend_Db_Select
|
||||
/**
|
||||
* Converts this object to an SQL SELECT string.
|
||||
*
|
||||
* @return string This object as a SELECT string.
|
||||
* @return string|null This object as a SELECT string. (or null if a string cannot be produced.)
|
||||
*/
|
||||
public function assemble()
|
||||
{
|
||||
@ -995,7 +995,7 @@ class Zend_Db_Select
|
||||
* Render DISTINCT clause
|
||||
*
|
||||
* @param string $sql SQL query
|
||||
* @return string
|
||||
* @return string|null
|
||||
*/
|
||||
protected function _renderColumns($sql)
|
||||
{
|
||||
|
@ -15,8 +15,9 @@
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Select
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @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 $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -28,7 +29,7 @@ require_once 'Zend/Db/Exception.php';
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Select
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
|
@ -15,8 +15,9 @@
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Statement
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @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 $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -35,7 +36,7 @@ require_once 'Zend/Db/Statement/Interface.php';
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Statement
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
abstract class Zend_Db_Statement implements Zend_Db_Statement_Interface
|
||||
|
@ -12,10 +12,12 @@
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Statement
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @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 $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -28,7 +30,7 @@ require_once 'Zend/Db/Statement.php';
|
||||
*
|
||||
* @package Zend_Db
|
||||
* @subpackage Statement
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Db_Statement_Db2 extends Zend_Db_Statement
|
||||
|
@ -12,10 +12,12 @@
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Statement
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @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 $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -26,7 +28,7 @@ require_once 'Zend/Db/Statement/Exception.php';
|
||||
/**
|
||||
* @package Zend_Db
|
||||
* @subpackage Statement
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
|
@ -15,8 +15,9 @@
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Statement
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @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 $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -30,7 +31,7 @@ require_once 'Zend/Db/Exception.php';
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Statement
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Db_Statement_Exception extends Zend_Db_Exception
|
||||
|
@ -15,8 +15,9 @@
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Statement
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @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: Interface.php 16541 2009-07-07 06:59:03Z bkarwin $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -25,7 +26,7 @@
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Statement
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
interface Zend_Db_Statement_Interface
|
||||
|
@ -15,9 +15,9 @@
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Statement
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @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 9738 2008-06-19 23:06:36Z peptolab $
|
||||
* @version $Id: Mysqli.php 17693 2009-08-20 16:34:59Z jimbojsb $
|
||||
*/
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@ require_once 'Zend/Db/Statement.php';
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Statement
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Db_Statement_Mysqli extends Zend_Db_Statement
|
||||
@ -81,7 +81,7 @@ class Zend_Db_Statement_Mysqli extends Zend_Db_Statement
|
||||
* @see Zend_Db_Statement_Mysqli_Exception
|
||||
*/
|
||||
require_once 'Zend/Db/Statement/Mysqli/Exception.php';
|
||||
throw new Zend_Db_Statement_Mysqli_Exception("Mysqli prepare error: " . $mysqli->error);
|
||||
throw new Zend_Db_Statement_Mysqli_Exception("Mysqli prepare error: " . $mysqli->error, $mysqli->errno);
|
||||
}
|
||||
}
|
||||
|
||||
@ -125,7 +125,9 @@ class Zend_Db_Statement_Mysqli extends Zend_Db_Statement
|
||||
{
|
||||
if ($stmt = $this->_stmt) {
|
||||
$mysqli = $this->_adapter->getConnection();
|
||||
while ($mysqli->next_result()) {}
|
||||
while ($mysqli->more_results()) {
|
||||
$mysqli->next_result();
|
||||
}
|
||||
$this->_stmt->free_result();
|
||||
return $this->_stmt->reset();
|
||||
}
|
||||
@ -199,10 +201,14 @@ class Zend_Db_Statement_Mysqli extends Zend_Db_Statement
|
||||
// send $params as input parameters to the statement
|
||||
if ($params) {
|
||||
array_unshift($params, str_repeat('s', count($params)));
|
||||
$stmtParams = array();
|
||||
foreach ($params as $k => &$value) {
|
||||
$stmtParams[$k] = &$value;
|
||||
}
|
||||
call_user_func_array(
|
||||
array($this->_stmt, 'bind_param'),
|
||||
$params
|
||||
);
|
||||
$stmtParams
|
||||
);
|
||||
}
|
||||
|
||||
// execute the statement
|
||||
@ -212,7 +218,7 @@ class Zend_Db_Statement_Mysqli extends Zend_Db_Statement
|
||||
* @see Zend_Db_Statement_Mysqli_Exception
|
||||
*/
|
||||
require_once 'Zend/Db/Statement/Mysqli/Exception.php';
|
||||
throw new Zend_Db_Statement_Mysqli_Exception("Mysqli statement execute error : " . $this->_stmt->error);
|
||||
throw new Zend_Db_Statement_Mysqli_Exception("Mysqli statement execute error : " . $this->_stmt->error, $this->_stmt->errno);
|
||||
}
|
||||
|
||||
|
||||
@ -224,7 +230,7 @@ class Zend_Db_Statement_Mysqli extends Zend_Db_Statement
|
||||
* @see Zend_Db_Statement_Mysqli_Exception
|
||||
*/
|
||||
require_once 'Zend/Db/Statement/Mysqli/Exception.php';
|
||||
throw new Zend_Db_Statement_Mysqli_Exception("Mysqli statement metadata error: " . $this->_stmt->error);
|
||||
throw new Zend_Db_Statement_Mysqli_Exception("Mysqli statement metadata error: " . $this->_stmt->error, $this->_stmt->errno);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,10 +12,12 @@
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Statement
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @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 $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -26,7 +28,7 @@ require_once 'Zend/Db/Statement/Exception.php';
|
||||
/**
|
||||
* @package Zend_Db
|
||||
* @subpackage Statement
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
|
@ -15,8 +15,9 @@
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Statement
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @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 $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -30,7 +31,7 @@ require_once 'Zend/Db/Statement.php';
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Statement
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Db_Statement_Oracle extends Zend_Db_Statement
|
||||
|
@ -15,8 +15,9 @@
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Statement
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @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 $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -28,7 +29,7 @@ require_once 'Zend/Db/Statement/Exception.php';
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Statement
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
|
@ -15,9 +15,9 @@
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Statement
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @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 4874 2007-05-19 01:26:32Z bkarwin $
|
||||
* @version $Id: Pdo.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -34,7 +34,7 @@ require_once 'Zend/Db/Statement.php';
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Statement
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Db_Statement_Pdo extends Zend_Db_Statement implements IteratorAggregate
|
||||
|
@ -15,9 +15,9 @@
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Statement
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @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 4874 2007-05-19 01:26:32Z bkarwin $
|
||||
* @version $Id: Ibm.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -34,7 +34,7 @@ require_once 'Zend/Db/Statement/Pdo.php';
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Statement
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Db_Statement_Pdo_Ibm extends Zend_Db_Statement_Pdo
|
||||
|
@ -15,9 +15,9 @@
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Statement
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @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 4874 2007-05-19 01:26:32Z bkarwin $
|
||||
* @version $Id: Oci.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -34,7 +34,7 @@ require_once 'Zend/Db/Statement/Pdo.php';
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Statement
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Db_Statement_Pdo_Oci extends Zend_Db_Statement_Pdo
|
||||
|
414
libs/Zend/Db/Statement/Sqlsrv.php
Normal file
414
libs/Zend/Db/Statement/Sqlsrv.php
Normal file
@ -0,0 +1,414 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @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
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Db_Statement
|
||||
*/
|
||||
require_once 'Zend/Db/Statement.php';
|
||||
|
||||
/**
|
||||
* Extends for Microsoft SQL Server Driver for PHP
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @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
|
||||
*/
|
||||
class Zend_Db_Statement_Sqlsrv extends Zend_Db_Statement
|
||||
{
|
||||
/**
|
||||
* The connection_stmt object.
|
||||
*/
|
||||
protected $_stmt;
|
||||
|
||||
/**
|
||||
* The connection_stmt object original string.
|
||||
*/
|
||||
protected $_originalSQL;
|
||||
|
||||
/**
|
||||
* Column names.
|
||||
*/
|
||||
protected $_keys;
|
||||
|
||||
/**
|
||||
* Query executed
|
||||
*/
|
||||
protected $_executed = false;
|
||||
|
||||
/**
|
||||
* Prepares statement handle
|
||||
*
|
||||
* @param string $sql
|
||||
* @return void
|
||||
* @throws Zend_Db_Statement_Sqlsrv_Exception
|
||||
*/
|
||||
protected function _prepare($sql)
|
||||
{
|
||||
$connection = $this->_adapter->getConnection();
|
||||
|
||||
$this->_stmt = sqlsrv_prepare($connection, $sql);
|
||||
|
||||
if (!$this->_stmt) {
|
||||
require_once 'Zend/Db/Statement/Sqlsrv/Exception.php';
|
||||
throw new Zend_Db_Statement_Sqlsrv_Exception(sqlsrv_errors());
|
||||
}
|
||||
|
||||
$this->_originalSQL = $sql;
|
||||
}
|
||||
|
||||
/**
|
||||
* Binds a parameter to the specified variable name.
|
||||
*
|
||||
* @param mixed $parameter Name the parameter, either integer or string.
|
||||
* @param mixed $variable Reference to PHP variable containing the value.
|
||||
* @param mixed $type OPTIONAL Datatype of SQL parameter.
|
||||
* @param mixed $length OPTIONAL Length of SQL parameter.
|
||||
* @param mixed $options OPTIONAL Other options.
|
||||
* @return bool
|
||||
* @throws Zend_Db_Statement_Exception
|
||||
*/
|
||||
protected function _bindParam($parameter, &$variable, $type = null, $length = null, $options = null)
|
||||
{
|
||||
//Sql server doesn't support bind by name
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the cursor, allowing the statement to be executed again.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function closeCursor()
|
||||
{
|
||||
if (!$this->_stmt) {
|
||||
return false;
|
||||
}
|
||||
|
||||
sqlsrv_free_stmt($this->_stmt);
|
||||
$this->_stmt = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of columns in the result set.
|
||||
* Returns null if the statement has no result set metadata.
|
||||
*
|
||||
* @return int The number of columns.
|
||||
*/
|
||||
public function columnCount()
|
||||
{
|
||||
if ($this->_stmt && $this->_executed) {
|
||||
return sqlsrv_num_fields($this->_stmt);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves the error code, if any, associated with the last operation on
|
||||
* the statement handle.
|
||||
*
|
||||
* @return string error code.
|
||||
*/
|
||||
public function errorCode()
|
||||
{
|
||||
if (!$this->_stmt) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$error = sqlsrv_errors();
|
||||
if (!$error) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $error[0]['code'];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves an array of error information, if any, associated with the
|
||||
* last operation on the statement handle.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function errorInfo()
|
||||
{
|
||||
if (!$this->_stmt) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$error = sqlsrv_errors();
|
||||
if (!$error) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return array(
|
||||
$error[0]['code'],
|
||||
$error[0]['message'],
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Executes a prepared statement.
|
||||
*
|
||||
* @param array $params OPTIONAL Values to bind to parameter placeholders.
|
||||
* @return bool
|
||||
* @throws Zend_Db_Statement_Exception
|
||||
*/
|
||||
public function _execute(array $params = null)
|
||||
{
|
||||
$connection = $this->_adapter->getConnection();
|
||||
if (!$this->_stmt) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($params !== null) {
|
||||
if (!is_array($params)) {
|
||||
$params = array($params);
|
||||
}
|
||||
$error = false;
|
||||
|
||||
// make all params passed by reference
|
||||
$params_ = array();
|
||||
$temp = array();
|
||||
$i = 1;
|
||||
foreach ($params as $param) {
|
||||
$temp[$i] = $param;
|
||||
$params_[] = &$temp[$i];
|
||||
$i++;
|
||||
}
|
||||
$params = $params_;
|
||||
}
|
||||
|
||||
$this->_stmt = sqlsrv_query($connection, $this->_originalSQL, $params);
|
||||
|
||||
if (!$this->_stmt) {
|
||||
require_once 'Zend/Db/Statement/Sqlsrv/Exception.php';
|
||||
throw new Zend_Db_Statement_Sqlsrv_Exception(sqlsrv_errors());
|
||||
}
|
||||
|
||||
$this->_executed = true;
|
||||
|
||||
return (!$this->_stmt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches a row from the result set.
|
||||
*
|
||||
* @param int $style OPTIONAL Fetch mode for this fetch operation.
|
||||
* @param int $cursor OPTIONAL Absolute, relative, or other.
|
||||
* @param int $offset OPTIONAL Number for absolute or relative cursors.
|
||||
* @return mixed Array, object, or scalar depending on fetch mode.
|
||||
* @throws Zend_Db_Statement_Exception
|
||||
*/
|
||||
public function fetch($style = null, $cursor = null, $offset = null)
|
||||
{
|
||||
if (!$this->_stmt) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (null === $style) {
|
||||
$style = $this->_fetchMode;
|
||||
}
|
||||
|
||||
$values = sqlsrv_fetch_array($this->_stmt, SQLSRV_FETCH_ASSOC);
|
||||
|
||||
if (!$values && (null !== $error = sqlsrv_errors())) {
|
||||
require_once 'Zend/Db/Statement/Sqlsrv/Exception.php';
|
||||
throw new Zend_Db_Statement_Sqlsrv_Exception($error);
|
||||
}
|
||||
|
||||
if (null === $values) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!$this->_keys) {
|
||||
foreach ($values as $key => $value) {
|
||||
$this->_keys[] = $this->_adapter->foldCase($key);
|
||||
}
|
||||
}
|
||||
|
||||
$values = array_values($values);
|
||||
|
||||
$row = false;
|
||||
switch ($style) {
|
||||
case Zend_Db::FETCH_NUM:
|
||||
$row = $values;
|
||||
break;
|
||||
case Zend_Db::FETCH_ASSOC:
|
||||
$row = array_combine($this->_keys, $values);
|
||||
break;
|
||||
case Zend_Db::FETCH_BOTH:
|
||||
$assoc = array_combine($this->_keys, $values);
|
||||
$row = array_merge($values, $assoc);
|
||||
break;
|
||||
case Zend_Db::FETCH_OBJ:
|
||||
$row = (object) array_combine($this->_keys, $values);
|
||||
break;
|
||||
case Zend_Db::FETCH_BOUND:
|
||||
$assoc = array_combine($this->_keys, $values);
|
||||
$row = array_merge($values, $assoc);
|
||||
$row = $this->_fetchBound($row);
|
||||
break;
|
||||
default:
|
||||
require_once 'Zend/Db/Statement/Sqlsrv/Exception.php';
|
||||
throw new Zend_Db_Statement_Sqlsrv_Exception("Invalid fetch mode '$style' specified");
|
||||
break;
|
||||
}
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a single column from the next row of a result set.
|
||||
*
|
||||
* @param int $col OPTIONAL Position of the column to fetch.
|
||||
* @return string
|
||||
* @throws Zend_Db_Statement_Exception
|
||||
*/
|
||||
public function fetchColumn($col = 0)
|
||||
{
|
||||
if (!$this->_stmt) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!sqlsrv_fetch($this->_stmt)) {
|
||||
if (null !== $error = sqlsrv_errors()) {
|
||||
require_once 'Zend/Db/Statement/Sqlsrv/Exception.php';
|
||||
throw new Zend_Db_Statement_Sqlsrv_Exception($error);
|
||||
}
|
||||
|
||||
// If no error, there is simply no record
|
||||
return false;
|
||||
}
|
||||
|
||||
$data = sqlsrv_get_field($this->_stmt, $col); //0-based
|
||||
if ($data === false) {
|
||||
require_once 'Zend/Db/Statement/Sqlsrv/Exception.php';
|
||||
throw new Zend_Db_Statement_Sqlsrv_Exception(sqlsrv_errors());
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the next row and returns it as an object.
|
||||
*
|
||||
* @param string $class OPTIONAL Name of the class to create.
|
||||
* @param array $config OPTIONAL Constructor arguments for the class.
|
||||
* @return mixed One object instance of the specified class.
|
||||
* @throws Zend_Db_Statement_Exception
|
||||
*/
|
||||
public function fetchObject($class = 'stdClass', array $config = array())
|
||||
{
|
||||
if (!$this->_stmt) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$obj = sqlsrv_fetch_object($this->_stmt);
|
||||
|
||||
if ($error = sqlsrv_errors()) {
|
||||
require_once 'Zend/Db/Statement/Sqlsrv/Exception.php';
|
||||
throw new Zend_Db_Statement_Sqlsrv_Exception($error);
|
||||
}
|
||||
|
||||
/* @todo XXX handle parameters */
|
||||
|
||||
if (null === $obj) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns metadata for a column in a result set.
|
||||
*
|
||||
* @param int $column
|
||||
* @return mixed
|
||||
* @throws Zend_Db_Statement_Sqlsrv_Exception
|
||||
*/
|
||||
public function getColumnMeta($column)
|
||||
{
|
||||
$fields = sqlsrv_field_metadata($this->_stmt);
|
||||
|
||||
if (!$fields) {
|
||||
throw new Zend_Db_Statement_Sqlsrv_Exception('Column metadata can not be fetched');
|
||||
}
|
||||
|
||||
if (!isset($fields[$column])) {
|
||||
throw new Zend_Db_Statement_Sqlsrv_Exception('Column index does not exist in statement');
|
||||
}
|
||||
|
||||
return $fields[$column];
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the next rowset (result set) for a SQL statement that has
|
||||
* multiple result sets. An example is a stored procedure that returns
|
||||
* the results of multiple queries.
|
||||
*
|
||||
* @return bool
|
||||
* @throws Zend_Db_Statement_Exception
|
||||
*/
|
||||
public function nextRowset()
|
||||
{
|
||||
if (sqlsrv_next_result($this->_stmt) === false) {
|
||||
require_once 'Zend/Db/Statement/Sqlsrv/Exception.php';
|
||||
throw new Zend_Db_Statement_Sqlsrv_Exception(sqlsrv_errors());
|
||||
}
|
||||
|
||||
//else - moved to next (or there are no more rows)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of rows affected by the execution of the
|
||||
* last INSERT, DELETE, or UPDATE statement executed by this
|
||||
* statement object.
|
||||
*
|
||||
* @return int The number of rows affected.
|
||||
* @throws Zend_Db_Statement_Exception
|
||||
*/
|
||||
public function rowCount()
|
||||
{
|
||||
if (!$this->_stmt) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$this->_executed) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$num_rows = sqlsrv_rows_affected($this->_stmt);
|
||||
|
||||
// Strict check is necessary; 0 is a valid return value
|
||||
if ($num_rows === false) {
|
||||
require_once 'Zend/Db/Statement/Sqlsrv/Exception.php';
|
||||
throw new Zend_Db_Statement_Sqlsrv_Exception(sqlsrv_errors());
|
||||
}
|
||||
|
||||
return $num_rows;
|
||||
}
|
||||
}
|
59
libs/Zend/Db/Statement/Sqlsrv/Exception.php
Normal file
59
libs/Zend/Db/Statement/Sqlsrv/Exception.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @package Zend_Db
|
||||
* @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
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Db_Statement_Exception
|
||||
*/
|
||||
require_once 'Zend/Db/Statement/Exception.php';
|
||||
|
||||
/**
|
||||
* @package Zend_Db
|
||||
* @subpackage Statement
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Db_Statement_Sqlsrv_Exception extends Zend_Db_Statement_Exception
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* If $message is an array, the assumption is that the return value of
|
||||
* sqlsrv_errors() was provided. If so, it then retrieves the most recent
|
||||
* error from that stack, and sets the message and code based on it.
|
||||
*
|
||||
* @param null|array|string $message
|
||||
* @param null|int $code
|
||||
*/
|
||||
public function __construct($message = null, $code = 0)
|
||||
{
|
||||
if (is_array($message)) {
|
||||
// Error should be array of errors
|
||||
// We only need first one (?)
|
||||
if (isset($message[0])) {
|
||||
$message = $message[0];
|
||||
}
|
||||
|
||||
$code = (int) $message['code'];
|
||||
$message = (string) $message['message'];
|
||||
}
|
||||
parent::__construct($message, $code);
|
||||
}
|
||||
}
|
||||
|
@ -15,8 +15,9 @@
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Table
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @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 $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -24,16 +25,60 @@
|
||||
*/
|
||||
require_once 'Zend/Db/Table/Abstract.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Db_Table_Definition
|
||||
*/
|
||||
require_once 'Zend/Db/Table/Definition.php';
|
||||
|
||||
/**
|
||||
* Class for SQL table interface.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Table
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @deprecated since 0.9
|
||||
*/
|
||||
abstract class Zend_Db_Table extends Zend_Db_Table_Abstract
|
||||
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
|
||||
*/
|
||||
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, '
|
||||
. 'try extending Zend_Db_Table_Abstract in your extending classes.',
|
||||
E_USER_NOTICE
|
||||
);
|
||||
$config = array(self::ADAPTER => $config);
|
||||
} else {
|
||||
// process this as table with or without a definition
|
||||
if ($definition instanceof Zend_Db_Table_Definition
|
||||
&& $definition->hasTableConfig($config)) {
|
||||
// this will have DEFINITION_CONFIG_NAME & DEFINITION
|
||||
$config = $definition->getTableConfig($config);
|
||||
} else {
|
||||
$config = array(self::NAME => $config);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
parent::__construct($config);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -15,9 +15,9 @@
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Table
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @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 6320 2007-09-12 00:27:22Z bkarwin $
|
||||
* @version $Id: Abstract.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -41,13 +41,15 @@ require_once 'Zend/Db.php';
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Table
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
abstract class Zend_Db_Table_Abstract
|
||||
{
|
||||
|
||||
const ADAPTER = 'db';
|
||||
const DEFINITION = 'definition';
|
||||
const DEFINITION_CONFIG_NAME = 'definitionConfigName';
|
||||
const SCHEMA = 'schema';
|
||||
const NAME = 'name';
|
||||
const PRIMARY = 'primary';
|
||||
@ -75,6 +77,9 @@ abstract class Zend_Db_Table_Abstract
|
||||
const DEFAULT_CLASS = 'defaultClass';
|
||||
const DEFAULT_DB = 'defaultDb';
|
||||
|
||||
const SELECT_WITH_FROM_PART = true;
|
||||
const SELECT_WITHOUT_FROM_PART = false;
|
||||
|
||||
/**
|
||||
* Default Zend_Db_Adapter_Abstract object.
|
||||
*
|
||||
@ -82,6 +87,20 @@ abstract class Zend_Db_Table_Abstract
|
||||
*/
|
||||
protected static $_defaultDb;
|
||||
|
||||
/**
|
||||
* Optional Zend_Db_Table_Definition object
|
||||
*
|
||||
* @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.
|
||||
*
|
||||
@ -106,7 +125,7 @@ abstract class Zend_Db_Table_Abstract
|
||||
/**
|
||||
* The table name.
|
||||
*
|
||||
* @var array
|
||||
* @var string
|
||||
*/
|
||||
protected $_name = null;
|
||||
|
||||
@ -242,11 +261,33 @@ abstract class Zend_Db_Table_Abstract
|
||||
$config = array(self::ADAPTER => $config);
|
||||
}
|
||||
|
||||
foreach ($config as $key => $value) {
|
||||
if ($config) {
|
||||
$this->setOptions($config);
|
||||
}
|
||||
|
||||
$this->_setup();
|
||||
$this->init();
|
||||
}
|
||||
|
||||
/**
|
||||
* setOptions()
|
||||
*
|
||||
* @param array $options
|
||||
* @return Zend_Db_Table_Abstract
|
||||
*/
|
||||
public function setOptions(Array $options)
|
||||
{
|
||||
foreach ($options as $key => $value) {
|
||||
switch ($key) {
|
||||
case self::ADAPTER:
|
||||
$this->_setAdapter($value);
|
||||
break;
|
||||
case self::DEFINITION:
|
||||
$this->setDefinition($value);
|
||||
break;
|
||||
case self::DEFINITION_CONFIG_NAME:
|
||||
$this->setDefinitionConfigName($value);
|
||||
break;
|
||||
case self::SCHEMA:
|
||||
$this->_schema = (string) $value;
|
||||
break;
|
||||
@ -283,8 +324,51 @@ abstract class Zend_Db_Table_Abstract
|
||||
}
|
||||
}
|
||||
|
||||
$this->_setup();
|
||||
$this->init();
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* setDefinition()
|
||||
*
|
||||
* @param Zend_Db_Table_Definition $definition
|
||||
* @return Zend_Db_Table_Abstract
|
||||
*/
|
||||
public function setDefinition(Zend_Db_Table_Definition $definition)
|
||||
{
|
||||
$this->_definition = $definition;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* getDefinition()
|
||||
*
|
||||
* @return Zend_Db_Table_Definition|null
|
||||
*/
|
||||
public function getDefinition()
|
||||
{
|
||||
return $this->_definition;
|
||||
}
|
||||
|
||||
/**
|
||||
* setDefinitionConfigName()
|
||||
*
|
||||
* @param string $definition
|
||||
* @return Zend_Db_Table_Abstract
|
||||
*/
|
||||
public function setDefinitionConfigName($definitionConfigName)
|
||||
{
|
||||
$this->_definitionConfigName = $definitionConfigName;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* getDefinitionConfigName()
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDefinitionConfigName()
|
||||
{
|
||||
return $this->_definitionConfigName;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -376,6 +460,9 @@ abstract class Zend_Db_Table_Abstract
|
||||
public function getReference($tableClassname, $ruleKey = null)
|
||||
{
|
||||
$thisClass = get_class($this);
|
||||
if ($thisClass === 'Zend_Db_Table') {
|
||||
$thisClass = $this->_definitionConfigName;
|
||||
}
|
||||
$refMap = $this->_getReferenceMapNormalized();
|
||||
if ($ruleKey !== null) {
|
||||
if (!isset($refMap[$ruleKey])) {
|
||||
@ -808,9 +895,9 @@ abstract class Zend_Db_Table_Abstract
|
||||
* object whose name is "<table>_<column>_seq".
|
||||
*/
|
||||
if ($this->_sequence === true && $this->_db instanceof Zend_Db_Adapter_Pdo_Pgsql) {
|
||||
$this->_sequence = "{$this->_name}_{$pkIdentity}_seq";
|
||||
$this->_sequence = $this->_db->quoteIdentifier("{$this->_name}_{$pkIdentity}_seq");
|
||||
if ($this->_schema) {
|
||||
$this->_sequence = $this->_schema . '.' . $this->_sequence;
|
||||
$this->_sequence = $this->_db->quoteIdentifier($this->_schema) . '.' . $this->_sequence;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -904,12 +991,17 @@ abstract class Zend_Db_Table_Abstract
|
||||
/**
|
||||
* Returns an instance of a Zend_Db_Table_Select object.
|
||||
*
|
||||
* @param bool $withFromPart Whether or not to include the from part of the select based on the table
|
||||
* @return Zend_Db_Table_Select
|
||||
*/
|
||||
public function select()
|
||||
public function select($withFromPart = self::SELECT_WITHOUT_FROM_PART)
|
||||
{
|
||||
require_once 'Zend/Db/Table/Select.php';
|
||||
return new Zend_Db_Table_Select($this);
|
||||
$select = new Zend_Db_Table_Select($this);
|
||||
if ($withFromPart == self::SELECT_WITH_FROM_PART) {
|
||||
$select->from($this->info(self::NAME), Zend_Db_Table_Select::SQL_WILDCARD, $this->info(self::SCHEMA));
|
||||
}
|
||||
return $select;
|
||||
}
|
||||
|
||||
/**
|
||||
|
131
libs/Zend/Db/Table/Definition.php
Normal file
131
libs/Zend/Db/Table/Definition.php
Normal file
@ -0,0 +1,131 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @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 $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class for SQL table interface.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @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
|
||||
*/
|
||||
class Zend_Db_Table_Definition
|
||||
{
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $_tableConfigs = array();
|
||||
|
||||
/**
|
||||
* __construct()
|
||||
*
|
||||
* @param array|Zend_Config $options
|
||||
*/
|
||||
public function __construct($options = null)
|
||||
{
|
||||
if ($options instanceof Zend_Config) {
|
||||
$this->setConfig($options);
|
||||
} elseif (is_array($options)) {
|
||||
$this->setOptions($options);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* setConfig()
|
||||
*
|
||||
* @param Zend_Config $config
|
||||
* @return Zend_Db_Table_Definition
|
||||
*/
|
||||
public function setConfig(Zend_Config $config)
|
||||
{
|
||||
$this->setOptions($config->toArray());
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* setOptions()
|
||||
*
|
||||
* @param array $options
|
||||
* @return Zend_Db_Table_Definition
|
||||
*/
|
||||
public function setOptions(Array $options)
|
||||
{
|
||||
foreach ($options as $optionName => $optionValue) {
|
||||
$this->setTableConfig($optionName, $optionValue);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $tableName
|
||||
* @param array $tableConfig
|
||||
* @return Zend_Db_Table_Definition
|
||||
*/
|
||||
public function setTableConfig($tableName, array $tableConfig)
|
||||
{
|
||||
// @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()
|
||||
*
|
||||
* @param string $tableName
|
||||
* @return array
|
||||
*/
|
||||
public function getTableConfig($tableName)
|
||||
{
|
||||
return $this->_tableConfigs[$tableName];
|
||||
}
|
||||
|
||||
/**
|
||||
* removeTableConfig()
|
||||
*
|
||||
* @param string $tableName
|
||||
*/
|
||||
public function removeTableConfig($tableName)
|
||||
{
|
||||
unset($this->_tableConfigs[$tableName]);
|
||||
}
|
||||
|
||||
/**
|
||||
* hasTableConfig()
|
||||
*
|
||||
* @param string $tableName
|
||||
* @return bool
|
||||
*/
|
||||
public function hasTableConfig($tableName)
|
||||
{
|
||||
return (isset($this->_tableConfigs[$tableName]));
|
||||
}
|
||||
|
||||
}
|
@ -15,8 +15,9 @@
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Table
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @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 $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -28,7 +29,7 @@ require_once 'Zend/Db/Exception.php';
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Table
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Db_Table_Exception extends Zend_Db_Exception
|
||||
|
@ -15,9 +15,9 @@
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Table
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @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: Row.php 9101 2008-03-30 19:54:38Z thomas $
|
||||
* @version $Id: Row.php 16203 2009-06-21 18:56:17Z thomas $
|
||||
*/
|
||||
|
||||
|
||||
@ -34,7 +34,7 @@ require_once 'Zend/Db/Table/Row/Abstract.php';
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Table
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Db_Table_Row extends Zend_Db_Table_Row_Abstract
|
||||
|
@ -15,9 +15,9 @@
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Table
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @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 6332 2007-09-13 00:35:08Z bkarwin $
|
||||
* @version $Id: Abstract.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -29,7 +29,7 @@ require_once 'Zend/Db.php';
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Table
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
|
||||
@ -116,12 +116,8 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
|
||||
if (isset($config['table']) && $config['table'] instanceof Zend_Db_Table_Abstract) {
|
||||
$this->_table = $config['table'];
|
||||
$this->_tableClass = get_class($this->_table);
|
||||
} else if ($this->_tableClass !== null) {
|
||||
if (!class_exists($this->_tableClass)) {
|
||||
require_once 'Zend/Loader.php';
|
||||
Zend_Loader::loadClass($this->_tableClass);
|
||||
}
|
||||
$this->_table = new $this->_tableClass();
|
||||
} elseif ($this->_tableClass !== null) {
|
||||
$this->_table = $this->_getTableFromString($this->_tableClass);
|
||||
}
|
||||
|
||||
if (isset($config['data'])) {
|
||||
@ -545,20 +541,10 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
|
||||
if (count($pkDiffData) > 0) {
|
||||
$depTables = $this->_getTable()->getDependentTables();
|
||||
if (!empty($depTables)) {
|
||||
$db = $this->_getTable()->getAdapter();
|
||||
$pkNew = $this->_getPrimaryKey(true);
|
||||
$pkOld = $this->_getPrimaryKey(false);
|
||||
foreach ($depTables as $tableClass) {
|
||||
if (!class_exists($tableClass)) {
|
||||
try {
|
||||
require_once 'Zend/Loader.php';
|
||||
Zend_Loader::loadClass($tableClass);
|
||||
} catch (Zend_Exception $e) {
|
||||
require_once 'Zend/Db/Table/Row/Exception.php';
|
||||
throw new Zend_Db_Table_Row_Exception($e->getMessage());
|
||||
}
|
||||
}
|
||||
$t = new $tableClass(array('db' => $db));
|
||||
$t = $this->_getTableFromString($tableClass);
|
||||
$t->_cascadeUpdate($this->getTableClass(), $pkOld, $pkNew);
|
||||
}
|
||||
}
|
||||
@ -627,19 +613,9 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
|
||||
*/
|
||||
$depTables = $this->_getTable()->getDependentTables();
|
||||
if (!empty($depTables)) {
|
||||
$db = $this->_getTable()->getAdapter();
|
||||
$pk = $this->_getPrimaryKey();
|
||||
foreach ($depTables as $tableClass) {
|
||||
if (!class_exists($tableClass)) {
|
||||
try {
|
||||
require_once 'Zend/Loader.php';
|
||||
Zend_Loader::loadClass($tableClass);
|
||||
} catch (Zend_Exception $e) {
|
||||
require_once 'Zend/Db/Table/Row/Exception.php';
|
||||
throw new Zend_Db_Table_Row_Exception($e->getMessage());
|
||||
}
|
||||
}
|
||||
$t = new $tableClass(array('db' => $db));
|
||||
$t = $this->_getTableFromString($tableClass);
|
||||
$t->_cascadeDelete($this->getTableClass(), $pk);
|
||||
}
|
||||
}
|
||||
@ -859,7 +835,8 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
|
||||
*/
|
||||
protected function _prepareReference(Zend_Db_Table_Abstract $dependentTable, Zend_Db_Table_Abstract $parentTable, $ruleKey)
|
||||
{
|
||||
$map = $dependentTable->getReference(get_class($parentTable), $ruleKey);
|
||||
$parentTableName = (get_class($parentTable) === 'Zend_Db_Table') ? $parentTable->getDefinitionConfigName() : get_class($parentTable);
|
||||
$map = $dependentTable->getReference($parentTableName, $ruleKey);
|
||||
|
||||
if (!isset($map[Zend_Db_Table_Abstract::REF_COLUMNS])) {
|
||||
$parentInfo = $parentTable->info();
|
||||
@ -886,18 +863,10 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
|
||||
$db = $this->_getTable()->getAdapter();
|
||||
|
||||
if (is_string($dependentTable)) {
|
||||
if (!class_exists($dependentTable)) {
|
||||
try {
|
||||
require_once 'Zend/Loader.php';
|
||||
Zend_Loader::loadClass($dependentTable);
|
||||
} catch (Zend_Exception $e) {
|
||||
require_once 'Zend/Db/Table/Row/Exception.php';
|
||||
throw new Zend_Db_Table_Row_Exception($e->getMessage());
|
||||
}
|
||||
}
|
||||
$dependentTable = new $dependentTable(array('db' => $db));
|
||||
$dependentTable = $this->_getTableFromString($dependentTable);
|
||||
}
|
||||
if (! $dependentTable instanceof Zend_Db_Table_Abstract) {
|
||||
|
||||
if (!$dependentTable instanceof Zend_Db_Table_Abstract) {
|
||||
$type = gettype($dependentTable);
|
||||
if ($type == 'object') {
|
||||
$type = get_class($dependentTable);
|
||||
@ -906,6 +875,13 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
|
||||
throw new Zend_Db_Table_Row_Exception("Dependent table must be a Zend_Db_Table_Abstract, but it is $type");
|
||||
}
|
||||
|
||||
// even if we are interacting between a table defined in a class and a
|
||||
// table via extension, ensure to persist the definition
|
||||
if (($tableDefinition = $this->_table->getDefinition()) !== null
|
||||
&& ($dependentTable->getDefinition() == null)) {
|
||||
$dependentTable->setOptions(array(Zend_Db_Table_Abstract::DEFINITION => $tableDefinition));
|
||||
}
|
||||
|
||||
if ($select === null) {
|
||||
$select = $dependentTable->select();
|
||||
} else {
|
||||
@ -943,18 +919,10 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
|
||||
$db = $this->_getTable()->getAdapter();
|
||||
|
||||
if (is_string($parentTable)) {
|
||||
if (!class_exists($parentTable)) {
|
||||
try {
|
||||
require_once 'Zend/Loader.php';
|
||||
Zend_Loader::loadClass($parentTable);
|
||||
} catch (Zend_Exception $e) {
|
||||
require_once 'Zend/Db/Table/Row/Exception.php';
|
||||
throw new Zend_Db_Table_Row_Exception($e->getMessage());
|
||||
}
|
||||
}
|
||||
$parentTable = new $parentTable(array('db' => $db));
|
||||
$parentTable = $this->_getTableFromString($parentTable);
|
||||
}
|
||||
if (! $parentTable instanceof Zend_Db_Table_Abstract) {
|
||||
|
||||
if (!$parentTable instanceof Zend_Db_Table_Abstract) {
|
||||
$type = gettype($parentTable);
|
||||
if ($type == 'object') {
|
||||
$type = get_class($parentTable);
|
||||
@ -963,6 +931,13 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
|
||||
throw new Zend_Db_Table_Row_Exception("Parent table must be a Zend_Db_Table_Abstract, but it is $type");
|
||||
}
|
||||
|
||||
// even if we are interacting between a table defined in a class and a
|
||||
// table via extension, ensure to persist the definition
|
||||
if (($tableDefinition = $this->_table->getDefinition()) !== null
|
||||
&& ($parentTable->getDefinition() == null)) {
|
||||
$parentTable->setOptions(array(Zend_Db_Table_Abstract::DEFINITION => $tableDefinition));
|
||||
}
|
||||
|
||||
if ($select === null) {
|
||||
$select = $parentTable->select();
|
||||
} else {
|
||||
@ -971,6 +946,7 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
|
||||
|
||||
$map = $this->_prepareReference($this->_getTable(), $parentTable, $ruleKey);
|
||||
|
||||
// iterate the map, creating the proper wheres
|
||||
for ($i = 0; $i < count($map[Zend_Db_Table_Abstract::COLUMNS]); ++$i) {
|
||||
$dependentColumnName = $db->foldCase($map[Zend_Db_Table_Abstract::COLUMNS][$i]);
|
||||
$value = $this->_data[$dependentColumnName];
|
||||
@ -979,8 +955,18 @@ 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();
|
||||
$type = $parentInfo[Zend_Db_Table_Abstract::METADATA][$parentColumnName]['DATA_TYPE'];
|
||||
$select->where("$parentColumn = ?", $value, $type);
|
||||
|
||||
// determine where part
|
||||
$type = $parentInfo[Zend_Db_Table_Abstract::METADATA][$parentColumnName]['DATA_TYPE'];
|
||||
$nullable = $parentInfo[Zend_Db_Table_Abstract::METADATA][$parentColumnName]['NULLABLE'];
|
||||
if ($value === null && $nullable == true) {
|
||||
$select->where("$parentColumn IS NULL");
|
||||
} elseif ($value === null && $nullable == false) {
|
||||
return null;
|
||||
} else {
|
||||
$select->where("$parentColumn = ?", $value, $type);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $parentTable->fetchRow($select);
|
||||
@ -1001,18 +987,10 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
|
||||
$db = $this->_getTable()->getAdapter();
|
||||
|
||||
if (is_string($intersectionTable)) {
|
||||
if (!class_exists($intersectionTable)) {
|
||||
try {
|
||||
require_once 'Zend/Loader.php';
|
||||
Zend_Loader::loadClass($intersectionTable);
|
||||
} catch (Zend_Exception $e) {
|
||||
require_once 'Zend/Db/Table/Row/Exception.php';
|
||||
throw new Zend_Db_Table_Row_Exception($e->getMessage());
|
||||
}
|
||||
}
|
||||
$intersectionTable = new $intersectionTable(array('db' => $db));
|
||||
$intersectionTable = $this->_getTableFromString($intersectionTable);
|
||||
}
|
||||
if (! $intersectionTable instanceof Zend_Db_Table_Abstract) {
|
||||
|
||||
if (!$intersectionTable instanceof Zend_Db_Table_Abstract) {
|
||||
$type = gettype($intersectionTable);
|
||||
if ($type == 'object') {
|
||||
$type = get_class($intersectionTable);
|
||||
@ -1021,18 +999,17 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
|
||||
throw new Zend_Db_Table_Row_Exception("Intersection table must be a Zend_Db_Table_Abstract, but it is $type");
|
||||
}
|
||||
|
||||
if (is_string($matchTable)) {
|
||||
if (!class_exists($matchTable)) {
|
||||
try {
|
||||
require_once 'Zend/Loader.php';
|
||||
Zend_Loader::loadClass($matchTable);
|
||||
} catch (Zend_Exception $e) {
|
||||
require_once 'Zend/Db/Table/Row/Exception.php';
|
||||
throw new Zend_Db_Table_Row_Exception($e->getMessage());
|
||||
}
|
||||
}
|
||||
$matchTable = new $matchTable(array('db' => $db));
|
||||
// even if we are interacting between a table defined in a class and a
|
||||
// table via extension, ensure to persist the definition
|
||||
if (($tableDefinition = $this->_table->getDefinition()) !== null
|
||||
&& ($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') {
|
||||
@ -1042,6 +1019,13 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
|
||||
throw new Zend_Db_Table_Row_Exception("Match table must be a Zend_Db_Table_Abstract, but it is $type");
|
||||
}
|
||||
|
||||
// even if we are interacting between a table defined in a class and a
|
||||
// table via extension, ensure to persist the definition
|
||||
if (($tableDefinition = $this->_table->getDefinition()) !== null
|
||||
&& ($matchTable->getDefinition() == null)) {
|
||||
$matchTable->setOptions(array(Zend_Db_Table_Abstract::DEFINITION => $tableDefinition));
|
||||
}
|
||||
|
||||
if ($select === null) {
|
||||
$select = $matchTable->select();
|
||||
} else {
|
||||
@ -1168,4 +1152,46 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
|
||||
throw new Zend_Db_Table_Row_Exception("Unrecognized method '$method()'");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* _getTableFromString
|
||||
*
|
||||
* @param string $tableName
|
||||
* @return Zend_Db_Table_Abstract
|
||||
*/
|
||||
protected function _getTableFromString($tableName)
|
||||
{
|
||||
|
||||
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 {
|
||||
require_once 'Zend/Loader.php';
|
||||
Zend_Loader::loadClass($tableName);
|
||||
} catch (Zend_Exception $e) {
|
||||
require_once 'Zend/Db/Table/Row/Exception.php';
|
||||
throw new Zend_Db_Table_Row_Exception($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
$options = array();
|
||||
|
||||
if (($table = $this->_getTable())) {
|
||||
$options['db'] = $table->getAdapter();
|
||||
}
|
||||
|
||||
if (isset($tableDefinition) && $tableDefinition !== null) {
|
||||
$options[Zend_Db_Table_Abstract::DEFINITION] = $tableDefinition;
|
||||
}
|
||||
|
||||
return new $tableName($options);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,8 +15,9 @@
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Table
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @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 $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -28,7 +29,7 @@ require_once 'Zend/Db/Table/Exception.php';
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Table
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Db_Table_Row_Exception extends Zend_Db_Table_Exception
|
||||
|
@ -16,9 +16,9 @@
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Table
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @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: Rowset.php 8064 2008-02-16 10:58:39Z thomas $
|
||||
* @version $Id: Rowset.php 16203 2009-06-21 18:56:17Z thomas $
|
||||
*/
|
||||
|
||||
|
||||
@ -35,7 +35,7 @@ require_once 'Zend/Db/Table/Rowset/Abstract.php';
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Table
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Db_Table_Rowset extends Zend_Db_Table_Rowset_Abstract
|
||||
|
@ -15,16 +15,16 @@
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Table
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @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 5896 2007-07-27 20:04:24Z bkarwin $
|
||||
* @version $Id: Abstract.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Table
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
abstract class Zend_Db_Table_Rowset_Abstract implements SeekableIterator, Countable, ArrayAccess
|
||||
|
@ -15,8 +15,9 @@
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Table
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @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 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -28,7 +29,7 @@ require_once 'Zend/Db/Table/Exception.php';
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Table
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Db_Table_Rowset_Exception extends Zend_Db_Table_Exception
|
||||
|
@ -16,9 +16,9 @@
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Select
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @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 5308 2007-06-14 17:18:45Z bkarwin $
|
||||
* @version $Id: Select.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
*/
|
||||
|
||||
|
||||
@ -40,7 +40,7 @@ require_once 'Zend/Db/Table/Abstract.php';
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Table
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Db_Table_Select extends Zend_Db_Select
|
||||
@ -185,7 +185,7 @@ class Zend_Db_Table_Select extends Zend_Db_Select
|
||||
* 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.
|
||||
*
|
||||
* @return string This object as a SELECT string.
|
||||
* @return string|null This object as a SELECT string (or null if a string cannot be produced)
|
||||
*/
|
||||
public function assemble()
|
||||
{
|
||||
|
@ -15,8 +15,9 @@
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Select
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @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 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -28,7 +29,7 @@ require_once 'Zend/Db/Select/Exception.php';
|
||||
* @category Zend
|
||||
* @package Zend_Db
|
||||
* @subpackage Table
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
|
Reference in New Issue
Block a user