import v2.0.0.0_RC3 | 2012-07-01
https://github.com/lucanos/CommunityID -> http://www.itadmins.net/archives/357
This commit is contained in:
@ -17,7 +17,7 @@
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Abstract.php 16920 2009-07-21 13:32:28Z ralph $
|
||||
* @version $Id: Abstract.php 18951 2009-11-12 16:26:19Z alexander $
|
||||
*/
|
||||
|
||||
|
||||
@ -119,7 +119,7 @@ abstract class Zend_Db_Adapter_Pdo_Abstract extends Zend_Db_Adapter_Abstract
|
||||
if (isset($this->_config['persistent']) && ($this->_config['persistent'] == true)) {
|
||||
$this->_config['driver_options'][PDO::ATTR_PERSISTENT] = true;
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
$this->_connection = new PDO(
|
||||
$dsn,
|
||||
@ -141,7 +141,7 @@ abstract class Zend_Db_Adapter_Pdo_Abstract extends Zend_Db_Adapter_Abstract
|
||||
* @see Zend_Db_Adapter_Exception
|
||||
*/
|
||||
require_once 'Zend/Db/Adapter/Exception.php';
|
||||
throw new Zend_Db_Adapter_Exception($e->getMessage());
|
||||
throw new Zend_Db_Adapter_Exception($e->getMessage(), $e);
|
||||
}
|
||||
|
||||
}
|
||||
@ -241,7 +241,7 @@ abstract class Zend_Db_Adapter_Pdo_Abstract extends Zend_Db_Adapter_Abstract
|
||||
* @see Zend_Db_Statement_Exception
|
||||
*/
|
||||
require_once 'Zend/Db/Statement/Exception.php';
|
||||
throw new Zend_Db_Statement_Exception($e->getMessage());
|
||||
throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -258,10 +258,10 @@ abstract class Zend_Db_Adapter_Pdo_Abstract extends Zend_Db_Adapter_Abstract
|
||||
if ($sql instanceof Zend_Db_Select) {
|
||||
$sql = $sql->assemble();
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
$affected = $this->getConnection()->exec($sql);
|
||||
|
||||
|
||||
if ($affected === false) {
|
||||
$errorInfo = $this->getConnection()->errorInfo();
|
||||
/**
|
||||
@ -270,14 +270,14 @@ abstract class Zend_Db_Adapter_Pdo_Abstract extends Zend_Db_Adapter_Abstract
|
||||
require_once 'Zend/Db/Adapter/Exception.php';
|
||||
throw new Zend_Db_Adapter_Exception($errorInfo[2]);
|
||||
}
|
||||
|
||||
|
||||
return $affected;
|
||||
} catch (PDOException $e) {
|
||||
/**
|
||||
* @see Zend_Db_Adapter_Exception
|
||||
*/
|
||||
require_once 'Zend/Db/Adapter/Exception.php';
|
||||
throw new Zend_Db_Adapter_Exception($e->getMessage());
|
||||
throw new Zend_Db_Adapter_Exception($e->getMessage(), $e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Mssql.php 17792 2009-08-24 16:18:02Z ralph $
|
||||
* @version $Id: Mssql.php 18951 2009-11-12 16:26:19Z alexander $
|
||||
*/
|
||||
|
||||
|
||||
@ -254,7 +254,7 @@ class Zend_Db_Adapter_Pdo_Mssql extends Zend_Db_Adapter_Pdo_Abstract
|
||||
if ($schemaName != null) {
|
||||
$sql .= ", @table_owner = " . $this->quoteIdentifier($schemaName, true);
|
||||
}
|
||||
|
||||
|
||||
$stmt = $this->query($sql);
|
||||
$primaryKeysResult = $stmt->fetchAll(Zend_Db::FETCH_NUM);
|
||||
$primaryKeyColumn = array();
|
||||
@ -335,46 +335,46 @@ class Zend_Db_Adapter_Pdo_Mssql extends Zend_Db_Adapter_Pdo_Abstract
|
||||
'SELECT $1TOP ' . ($count+$offset) . ' ',
|
||||
$sql
|
||||
);
|
||||
|
||||
|
||||
if ($offset > 0) {
|
||||
$orderby = stristr($sql, 'ORDER BY');
|
||||
|
||||
if ($orderby !== false) {
|
||||
$orderParts = explode(',', substr($orderby, 8));
|
||||
$pregReplaceCount = null;
|
||||
$orderbyInverseParts = array();
|
||||
foreach ($orderParts as $orderPart) {
|
||||
$orderPart = rtrim($orderPart);
|
||||
$inv = preg_replace('/\s+desc$/i', ' ASC', $orderPart, 1, $pregReplaceCount);
|
||||
if ($pregReplaceCount) {
|
||||
$orderbyInverseParts[] = $inv;
|
||||
continue;
|
||||
}
|
||||
$inv = preg_replace('/\s+asc$/i', ' DESC', $orderPart, 1, $pregReplaceCount);
|
||||
if ($pregReplaceCount) {
|
||||
$orderbyInverseParts[] = $inv;
|
||||
continue;
|
||||
} else {
|
||||
$orderbyInverseParts[] = $orderPart . ' DESC';
|
||||
}
|
||||
}
|
||||
|
||||
$orderbyInverse = 'ORDER BY ' . implode(', ', $orderbyInverseParts);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$sql = 'SELECT * FROM (SELECT TOP ' . $count . ' * FROM (' . $sql . ') AS inner_tbl';
|
||||
if ($orderby !== false) {
|
||||
$sql .= ' ' . $orderbyInverse . ' ';
|
||||
}
|
||||
$sql .= ') AS outer_tbl';
|
||||
if ($orderby !== false) {
|
||||
$sql .= ' ' . $orderby;
|
||||
}
|
||||
$orderby = stristr($sql, 'ORDER BY');
|
||||
|
||||
if ($orderby !== false) {
|
||||
$orderParts = explode(',', substr($orderby, 8));
|
||||
$pregReplaceCount = null;
|
||||
$orderbyInverseParts = array();
|
||||
foreach ($orderParts as $orderPart) {
|
||||
$orderPart = rtrim($orderPart);
|
||||
$inv = preg_replace('/\s+desc$/i', ' ASC', $orderPart, 1, $pregReplaceCount);
|
||||
if ($pregReplaceCount) {
|
||||
$orderbyInverseParts[] = $inv;
|
||||
continue;
|
||||
}
|
||||
$inv = preg_replace('/\s+asc$/i', ' DESC', $orderPart, 1, $pregReplaceCount);
|
||||
if ($pregReplaceCount) {
|
||||
$orderbyInverseParts[] = $inv;
|
||||
continue;
|
||||
} else {
|
||||
$orderbyInverseParts[] = $orderPart . ' DESC';
|
||||
}
|
||||
}
|
||||
|
||||
$orderbyInverse = 'ORDER BY ' . implode(', ', $orderbyInverseParts);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$sql = 'SELECT * FROM (SELECT TOP ' . $count . ' * FROM (' . $sql . ') AS inner_tbl';
|
||||
if ($orderby !== false) {
|
||||
$sql .= ' ' . $orderbyInverse . ' ';
|
||||
}
|
||||
$sql .= ') AS outer_tbl';
|
||||
if ($orderby !== false) {
|
||||
$sql .= ' ' . $orderby;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Oci.php 16203 2009-06-21 18:56:17Z thomas $
|
||||
* @version $Id: Oci.php 19048 2009-11-19 18:15:05Z mikaelkael $
|
||||
*/
|
||||
|
||||
|
||||
@ -186,7 +186,7 @@ class Zend_Db_Adapter_Pdo_Oci extends Zend_Db_Adapter_Pdo_Abstract
|
||||
TC.DATA_SCALE, TC.DATA_PRECISION, C.CONSTRAINT_TYPE, CC.POSITION
|
||||
FROM ALL_TAB_COLUMNS TC
|
||||
LEFT JOIN (ALL_CONS_COLUMNS CC JOIN ALL_CONSTRAINTS C
|
||||
ON (CC.CONSTRAINT_NAME = C.CONSTRAINT_NAME AND CC.TABLE_NAME = C.TABLE_NAME AND C.CONSTRAINT_TYPE = 'P'))
|
||||
ON (CC.CONSTRAINT_NAME = C.CONSTRAINT_NAME AND CC.TABLE_NAME = C.TABLE_NAME AND CC.OWNER = C.OWNER AND C.CONSTRAINT_TYPE = 'P'))
|
||||
ON TC.TABLE_NAME = CC.TABLE_NAME AND TC.COLUMN_NAME = CC.COLUMN_NAME
|
||||
WHERE UPPER(TC.TABLE_NAME) = UPPER(:TBNAME)";
|
||||
$bind[':TBNAME'] = $tableName;
|
||||
|
@ -17,7 +17,7 @@
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Pgsql.php 16732 2009-07-15 12:44:36Z yoshida@zend.co.jp $
|
||||
* @version $Id: Pgsql.php 19051 2009-11-19 18:27:53Z mikaelkael $
|
||||
*/
|
||||
|
||||
|
||||
@ -99,19 +99,14 @@ class Zend_Db_Adapter_Pdo_Pgsql extends Zend_Db_Adapter_Pdo_Abstract
|
||||
*/
|
||||
public function listTables()
|
||||
{
|
||||
// @todo use a better query with joins instead of subqueries
|
||||
$sql = "SELECT c.relname AS table_name "
|
||||
. "FROM pg_class c, pg_user u "
|
||||
. "WHERE c.relowner = u.usesysid AND c.relkind = 'r' "
|
||||
. "AND NOT EXISTS (SELECT 1 FROM pg_views WHERE viewname = c.relname) "
|
||||
. "AND c.relname !~ '^(pg_|sql_)' "
|
||||
. "UNION "
|
||||
. "SELECT c.relname AS table_name "
|
||||
. "FROM pg_class c "
|
||||
. "WHERE c.relkind = 'r' "
|
||||
. "AND NOT EXISTS (SELECT 1 FROM pg_views WHERE viewname = c.relname) "
|
||||
. "AND NOT EXISTS (SELECT 1 FROM pg_user WHERE usesysid = c.relowner) "
|
||||
. "AND c.relname !~ '^pg_'";
|
||||
$sql = "SELECT c.relname AS table_name "
|
||||
. "FROM pg_catalog.pg_class c "
|
||||
. "JOIN pg_catalog.pg_roles r ON r.oid = c.relowner "
|
||||
. "LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace "
|
||||
. "WHERE n.nspname <> 'pg_catalog' "
|
||||
. "AND n.nspname !~ '^pg_toast' "
|
||||
. "AND pg_catalog.pg_table_is_visible(c.oid) "
|
||||
. "AND c.relkind = 'r' ";
|
||||
|
||||
return $this->fetchCol($sql);
|
||||
}
|
||||
@ -194,6 +189,7 @@ class Zend_Db_Adapter_Pdo_Pgsql extends Zend_Db_Adapter_Pdo_Abstract
|
||||
|
||||
$desc = array();
|
||||
foreach ($result as $key => $row) {
|
||||
$defaultValue = $row[$default_value];
|
||||
if ($row[$type] == 'varchar') {
|
||||
if (preg_match('/character varying(?:\((\d+)\))?/', $row[$complete_type], $matches)) {
|
||||
if (isset($matches[1])) {
|
||||
@ -202,6 +198,9 @@ class Zend_Db_Adapter_Pdo_Pgsql extends Zend_Db_Adapter_Pdo_Abstract
|
||||
$row[$length] = null; // unlimited
|
||||
}
|
||||
}
|
||||
if (preg_match("/^'(.*?)'::character varying$/", $defaultValue, $matches)) {
|
||||
$defaultValue = $matches[1];
|
||||
}
|
||||
}
|
||||
list($primary, $primaryPosition, $identity) = array(false, null, false);
|
||||
if ($row[$contype] == 'p') {
|
||||
@ -215,7 +214,7 @@ class Zend_Db_Adapter_Pdo_Pgsql extends Zend_Db_Adapter_Pdo_Abstract
|
||||
'COLUMN_NAME' => $this->foldCase($row[$colname]),
|
||||
'COLUMN_POSITION' => $row[$attnum],
|
||||
'DATA_TYPE' => $row[$type],
|
||||
'DEFAULT' => $row[$default_value],
|
||||
'DEFAULT' => $defaultValue,
|
||||
'NULLABLE' => (bool) ($row[$notnull] != 't'),
|
||||
'LENGTH' => $row[$length],
|
||||
'SCALE' => null, // @todo
|
||||
|
@ -17,7 +17,7 @@
|
||||
* @subpackage Adapter
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Sqlite.php 16203 2009-06-21 18:56:17Z thomas $
|
||||
* @version $Id: Sqlite.php 18951 2009-11-12 16:26:19Z alexander $
|
||||
*/
|
||||
|
||||
|
||||
@ -197,12 +197,14 @@ class Zend_Db_Adapter_Pdo_Sqlite extends Zend_Db_Adapter_Pdo_Abstract
|
||||
*/
|
||||
public function describeTable($tableName, $schemaName = null)
|
||||
{
|
||||
$sql = 'PRAGMA ';
|
||||
|
||||
if ($schemaName) {
|
||||
$sql = "PRAGMA $schemaName.table_info($tableName)";
|
||||
} else {
|
||||
$sql = "PRAGMA table_info($tableName)";
|
||||
$sql .= $this->quoteIdentifier($schemaName) . '.';
|
||||
}
|
||||
|
||||
$sql .= 'table_info('.$this->quoteIdentifier($tableName).')';
|
||||
|
||||
$stmt = $this->query($sql);
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user