diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php
index 8d1b1c2e6..168129031 100644
--- a/cake/libs/model/datasources/dbo/dbo_mysql.php
+++ b/cake/libs/model/datasources/dbo/dbo_mysql.php
@@ -419,7 +419,10 @@ class DboMysql extends DboSource {
function length($real) {
$col = r(array(')', 'unsigned'), '', $real);
$limit = null;
- @list($col, $limit) = explode('(', $col);
+
+ if (strpos($col, '(') !== false) {
+ list($col, $limit) = explode('(', $col);
+ }
if ($limit != null) {
return intval($limit);
diff --git a/cake/libs/model/datasources/dbo/dbo_oracle.php b/cake/libs/model/datasources/dbo/dbo_oracle.php
index 7bf5bca8b..38aea1ef2 100644
--- a/cake/libs/model/datasources/dbo/dbo_oracle.php
+++ b/cake/libs/model/datasources/dbo/dbo_oracle.php
@@ -7,8 +7,8 @@
*
* PHP versions 4 and 5
*
- * CakePHP(tm) : Rapid Development Framework
- * Copyright 2005-2007, Cake Software Foundation, Inc.
+ * CakePHP : Rapid Development Framework
+ * Copyright (c) 2006, Cake Software Foundation, Inc.
* 1785 E. Sahara Avenue, Suite 490-204
* Las Vegas, Nevada 89104
*
@@ -16,20 +16,17 @@
* Redistributions of files must retain the above copyright notice.
*
* @filesource
- * @copyright Copyright 2005-2007, Cake Software Foundation, Inc.
- * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @copyright Copyright (c) 2006, Cake Software Foundation, Inc.
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
* @package cake
* @subpackage cake.cake.libs.model.dbo
- * @since CakePHP(tm) v 1.1.11.4041
+ * @since CakePHP v 1.1.11.4041
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
-/**
- * Include DBO.
- */
-uses('model'.DS.'datasources'.DS.'dbo_source');
+
/**
* Short description for class.
*
@@ -39,90 +36,97 @@ uses('model'.DS.'datasources'.DS.'dbo_source');
* @subpackage cake.cake.libs.model.dbo
*/
class DboOracle extends DboSource {
- /**
+
+/**
* Enter description here...
*
* @var unknown_type
* @access public
*/
var $config;
- /**
+/**
* Enter description here...
*
* @var unknown_type
* @access public
*/
var $alias = '';
-
- /**
- * The name of the model's sequence
- *
- * @var unknown_type
- */
+/**
+ * The name of the model's sequence
+ *
+ * @var unknown_type
+ */
var $sequence = '';
-
+/**
+ * Transaction in progress flag
+ *
+ * @var boolean
+ */
+ var $_transactionStarted = false;
/**
* Enter description here...
*
* @var unknown_type
* @access public
*/
- var $columns = array('primary_key' => array('name' => 'number NOT NULL'),
- 'string' => array('name' => 'varchar2', 'limit' => '255'),
- 'text' => array('name' => 'varchar2'),
- 'integer' => array('name' => 'numeric'),
- 'float' => array('name' => 'float'),
- 'datetime' => array('name' => 'date'),
- 'timestamp' => array('name' => 'date'),
- 'time' => array('name' => 'date'),
- 'date' => array('name' => 'date'),
- 'binary' => array('name' => 'bytea'),
- 'boolean' => array('name' => 'boolean'),
- 'number' => array('name' => 'numeric'),
- 'inet' => array('name' => 'inet'));
- /**
+ var $columns = array(
+ 'primary_key' => array('name' => 'number NOT NULL'),
+ 'string' => array('name' => 'varchar2', 'limit' => '255'),
+ 'text' => array('name' => 'varchar2'),
+ 'integer' => array('name' => 'numeric'),
+ 'float' => array('name' => 'float'),
+ 'datetime' => array('name' => 'date'),
+ 'timestamp' => array('name' => 'date'),
+ 'time' => array('name' => 'date'),
+ 'date' => array('name' => 'date'),
+ 'binary' => array('name' => 'bytea'),
+ 'boolean' => array('name' => 'boolean'),
+ 'number' => array('name' => 'numeric'),
+ 'inet' => array('name' => 'inet')
+ );
+/**
* Enter description here...
*
* @var unknown_type
* @access protected
*/
var $connection;
- /**
+/**
* Enter description here...
*
* @var unknown_type
* @access protected
*/
var $_limit = -1;
- /**
+/**
* Enter description here...
*
* @var unknown_type
* @access protected
*/
var $_offset = 0;
- /**
+/**
* Enter description here...
*
* @var unknown_type
* @access protected
*/
var $_map;
- /**
+/**
* Enter description here...
*
* @var unknown_type
* @access protected
*/
var $_currentRow;
- /**
+/**
* Enter description here...
*
* @var unknown_type
* @access protected
*/
var $_numRows;
- /**
+/**
* Enter description here...
*
* @var unknown_type
@@ -150,6 +154,35 @@ class DboOracle extends DboSource {
}
return $this->connected;
}
+
+ /**
+ * Sets the encoding language of the session
+ *
+ * @param string $lang language constant
+ * @return boolean
+ */
+ function setEncoding($lang) {
+ if (!$this->execute('ALTER SESSION SET NLS_LANGUAGE='.$lang)) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Gets the current encoding language
+ *
+ * @return string language constant
+ */
+ function getEncoding() {
+ $sql = 'SELECT VALUE FROM NLS_SESSION_PARAMETERS WHERE PARAMETER=\'NLS_LANGUAGE\'';
+ if (!$this->execute($sql)) {
+ return false;
+ }
+ if (!$row = $this->fetchRow()) {
+ return false;
+ }
+ return $row[0]['VALUE'];
+ }
/**
* Disconnects from database.
@@ -202,6 +235,8 @@ class DboOracle extends DboSource {
}
$this->_map[] = array($table, $field);
}
+
+
}
/**
* Modify a SQL query to limit (and offset) the result set
@@ -233,7 +268,7 @@ class DboOracle extends DboSource {
* @return resource Result resource identifier or null
* @access protected
*/
- function _execute($sql) {
+ function _execute($sql) {
$this->_statementId = ociparse($this->connection, $sql);
if (!$this->_statementId) {
return null;
@@ -246,6 +281,7 @@ class DboOracle extends DboSource {
if (!ociexecute($this->_statementId, $mode)) {
return false;
}
+
// fetch occurs here instead of fetchResult in order to get the number of rows
switch (ocistatementtype($this->_statementId)) {
case 'DESCRIBE':
@@ -261,7 +297,7 @@ class DboOracle extends DboSource {
ocisetprefetch($this->_statementId, 3000);
}
$this->_numRows = ocifetchstatement($this->_statementId, $this->_results, $this->_offset, $this->_limit, OCI_NUM | OCI_FETCHSTATEMENT_BY_ROW);
- $this->_currentRow = 0;
+ $this->_currentRow = 0;
return $this->_statementId;
}
/**
@@ -273,6 +309,10 @@ class DboOracle extends DboSource {
function fetchRow() {
if ($this->_currentRow >= $this->_numRows) {
ocifreestatement($this->_statementId);
+ $this->_map = null;
+ $this->_results = null;
+ $this->_currentRow = null;
+ $this->_numRows = null;
return false;
}
$resultRow = array();
@@ -353,7 +393,7 @@ class DboOracle extends DboSource {
return $cache;
}
$sql = 'SELECT COLUMN_NAME, DATA_TYPE FROM user_tab_columns WHERE table_name = \'';
- $sql .= strtoupper($model->table) . '\'';
+ $sql .= strtoupper($this->fullTableName($model)) . '\'';
if (!$this->execute($sql)) {
return false;
}
@@ -362,8 +402,7 @@ class DboOracle extends DboSource {
$fields[$i]['name'] = strtolower($row[0]['COLUMN_NAME']);
$fields[$i]['type'] = $this->column($row[0]['DATA_TYPE']);
}
- $this->__cacheDescription($model->tablePrefix.$model->table, $fields);
- //$this->__cacheDescription($this->fullTableName($model, false), $fields);
+ $this->__cacheDescription($this->fullTableName($model, false), $fields);
return $fields;
}
/**
@@ -394,7 +433,7 @@ class DboOracle extends DboSource {
* @return boolean True on success, false on fail
* (i.e. if the database/model does not support transactions).
*/
- function begin(&$model) {
+ function begin() {
//if (parent::begin($model)) {
//if ($this->execute('BEGIN')) {
$this->_transactionStarted = true;
@@ -425,7 +464,7 @@ class DboOracle extends DboSource {
* (i.e. if the database/model does not support transactions,
* or a transaction has not started).
*/
- function commit(&$model) {
+ function commit() {
//if (parent::commit($model)) {
$this->_transactionStarted = false;
return ocicommit($this->connection);
diff --git a/cake/libs/model/datasources/dbo/dbo_postgres.php b/cake/libs/model/datasources/dbo/dbo_postgres.php
index e249b719d..bb25fb9cc 100644
--- a/cake/libs/model/datasources/dbo/dbo_postgres.php
+++ b/cake/libs/model/datasources/dbo/dbo_postgres.php
@@ -47,7 +47,8 @@ class DboPostgres extends DboSource {
'login' => 'root',
'password' => '',
'database' => 'cake',
- 'port' => 5432
+ 'port' => 5432,
+ 'encoding' => ''
);
var $columns = array(
@@ -86,8 +87,7 @@ class DboPostgres extends DboSource {
} else {
$this->connected = false;
}
-
- if (isset($config['encoding']) && !empty($config['encoding'])) {
+ if (!empty($config['encoding'])) {
$this->setEncoding($config['encoding']);
}
diff --git a/cake/libs/model/datasources/dbo/dbo_sybase.php b/cake/libs/model/datasources/dbo/dbo_sybase.php
index bf4d43694..ea467b061 100644
--- a/cake/libs/model/datasources/dbo/dbo_sybase.php
+++ b/cake/libs/model/datasources/dbo/dbo_sybase.php
@@ -36,51 +36,54 @@
*/
class DboSybase extends DboSource {
/**
- * Enter description here...
+ * Driver description
*
- * @var unknown_type
+ * @var string
*/
var $description = "Sybase DBO Driver";
/**
- * Enter description here...
+ * Start quote for quoted identifiers
*
- * @var unknown_type
+ * @var string
*/
var $startQuote = "`";
/**
- * Enter description here...
+ * End quote for quoted identifiers
*
- * @var unknown_type
+ * @var string
*/
var $endQuote = "`";
/**
- * Base configuration settings for MySQL driver
+ * Base configuration settings for Sybase driver
*
* @var array
*/
- var $_baseConfig = array('persistent' => true,
- 'host' => 'localhost',
- 'login' => 'root',
- 'password' => '',
- 'database' => 'cake',
- 'port' => '3306',
- 'connect' => 'sybase_pconnect');
+ var $_baseConfig = array(
+ 'persistent' => true,
+ 'host' => 'localhost',
+ 'login' => 'sa',
+ 'password' => '',
+ 'database' => 'cake',
+ 'port' => '4100'
+ );
/**
- * MySQL column definition
+ * Sybase column definition
*
* @var array
*/
- var $columns = array('primary_key' => array('name' => 'int(11) DEFAULT NULL auto_increment'),
- 'string' => array('name' => 'varchar', 'limit' => '255'),
- 'text' => array('name' => 'text'),
- 'integer' => array('name' => 'int', 'limit' => '11', 'formatter' => 'intval'),
- 'float' => array('name' => 'float', 'formatter' => 'floatval'),
- 'datetime' => array('name' => 'datetime', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'),
- 'timestamp' => array('name' => 'timestamp', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'),
- 'time' => array('name' => 'time', 'format' => 'H:i:s', 'formatter' => 'date'),
- 'date' => array('name' => 'date', 'format' => 'Y-m-d', 'formatter' => 'date'),
- 'binary' => array('name' => 'blob'),
- 'boolean' => array('name' => 'tinyint', 'limit' => '1'));
+ var $columns = array(
+ 'primary_key' => array('name' => 'numeric(9,0) IDENTITY PRIMARY KEY'),
+ 'string' => array('name' => 'varchar', 'limit' => '255'),
+ 'text' => array('name' => 'text'),
+ 'integer' => array('name' => 'int', 'limit' => '11', 'formatter' => 'intval'),
+ 'float' => array('name' => 'float', 'formatter' => 'floatval'),
+ 'datetime' => array('name' => 'datetime', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'),
+ 'timestamp' => array('name' => 'timestamp', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'),
+ 'time' => array('name' => 'datetime', 'format' => 'H:i:s', 'formatter' => 'date'),
+ 'date' => array('name' => 'datetime', 'format' => 'Y-m-d', 'formatter' => 'date'),
+ 'binary' => array('name' => 'image'),
+ 'boolean' => array('name' => 'bit')
+ );
/**
* Connects to the database using options in the given configuration array.
*
@@ -88,13 +91,12 @@ class DboSybase extends DboSource {
*/
function connect() {
$config = $this->config;
- $connect = $config['connect'];
$this->connected = false;
if (!$config['persistent']) {
$this->connection = sybase_connect($config['host'], $config['login'], $config['password'], true);
} else {
- $this->connection = $connect($config['host'], $config['login'], $config['password']);
+ $this->connection = sybase_pconnect($config['host'], $config['login'], $config['password']);
}
if (sybase_select_db($config['database'], $this->connection)) {
@@ -132,7 +134,7 @@ class DboSybase extends DboSource {
return $cache;
}
- $result = $this->_execute("SHOW TABLES FROM " . $this->config['database']);
+ $result = $this->_execute("select name from sysobjects where type='U'");
if (!$result) {
return array();
} else {
@@ -234,7 +236,7 @@ class DboSybase extends DboSource {
*/
function begin(&$model) {
if (parent::begin($model)) {
- if ($this->execute('START TRANSACTION')) {
+ if ($this->execute('BEGIN TRAN')) {
$this->_transactionStarted = true;
return true;
}
@@ -252,7 +254,7 @@ class DboSybase extends DboSource {
function commit(&$model) {
if (parent::commit($model)) {
$this->_transactionStarted = false;
- return $this->execute('COMMIT');
+ return $this->execute('COMMIT TRAN');
}
return false;
}
@@ -266,7 +268,7 @@ class DboSybase extends DboSource {
*/
function rollback(&$model) {
if (parent::rollback($model)) {
- return $this->execute('ROLLBACK');
+ return $this->execute('ROLLBACK TRAN');
}
return false;
}
@@ -342,29 +344,18 @@ class DboSybase extends DboSource {
$limit = null;
@list($col, $limit) = explode('(', $col);
- if (in_array($col, array('date', 'time', 'datetime', 'timestamp'))) {
- return $col;
- }
- if ($col == 'tinyint' && $limit == '1') {
- return 'boolean';
- }
- if (strpos($col, 'int') !== false) {
+ if (in_array($col, array('datetime', 'smalldatetime'))) {
+ return 'datetime';
+ } elseif (in_array($col, array('int', 'bigint', 'smallint', 'tinyint'))) {
return 'integer';
- }
- if (strpos($col, 'char') !== false || $col == 'tinytext') {
- return 'string';
- }
- if (strpos($col, 'text') !== false) {
- return 'text';
- }
- if (strpos($col, 'blob') !== false) {
- return 'binary';
- }
- if (in_array($col, array('float', 'double', 'decimal'))) {
+ } elseif (in_array($col, array('float', 'double', 'real', 'decimal', 'money', 'numeric', 'smallmoney'))) {
return 'float';
- }
- if (strpos($col, 'enum') !== false) {
- return "enum($limit)";
+ } elseif (strpos($col, 'text') !== false) {
+ return 'text';
+ } elseif (in_array($col, array('char', 'nchar', 'nvarchar', 'string', 'varchar'))) {
+ return 'binary';
+ } elseif (in_array($col, array('binary', 'image', 'varbinary'))) {
+ return 'binary';
}
return 'text';