mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 11:06:15 +00:00
Fixed #5800. Fixed INSERTs broken by refactoring of DboSource::renderStatement()
Also added slightly more support for CakeSchema with DboOracle git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7912 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
8c51d72ed8
commit
caa063590d
2 changed files with 52 additions and 3 deletions
|
@ -63,10 +63,10 @@ class DboOracle extends DboSource {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $columns = array(
|
var $columns = array(
|
||||||
'primary_key' => array('name' => 'number NOT NULL'),
|
'primary_key' => array('name' => ''),
|
||||||
'string' => array('name' => 'varchar2', 'limit' => '255'),
|
'string' => array('name' => 'varchar2', 'limit' => '255'),
|
||||||
'text' => array('name' => 'varchar2'),
|
'text' => array('name' => 'varchar2'),
|
||||||
'integer' => array('name' => 'numeric'),
|
'integer' => array('name' => 'number'),
|
||||||
'float' => array('name' => 'float'),
|
'float' => array('name' => 'float'),
|
||||||
'datetime' => array('name' => 'date', 'format' => 'Y-m-d H:i:s'),
|
'datetime' => array('name' => 'date', 'format' => 'Y-m-d H:i:s'),
|
||||||
'timestamp' => array('name' => 'date', 'format' => 'Y-m-d H:i:s'),
|
'timestamp' => array('name' => 'date', 'format' => 'Y-m-d H:i:s'),
|
||||||
|
@ -74,7 +74,7 @@ class DboOracle extends DboSource {
|
||||||
'date' => array('name' => 'date', 'format' => 'Y-m-d H:i:s'),
|
'date' => array('name' => 'date', 'format' => 'Y-m-d H:i:s'),
|
||||||
'binary' => array('name' => 'bytea'),
|
'binary' => array('name' => 'bytea'),
|
||||||
'boolean' => array('name' => 'boolean'),
|
'boolean' => array('name' => 'boolean'),
|
||||||
'number' => array('name' => 'numeric'),
|
'number' => array('name' => 'number'),
|
||||||
'inet' => array('name' => 'inet'));
|
'inet' => array('name' => 'inet'));
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
|
@ -904,6 +904,9 @@ class DboOracle extends DboSource {
|
||||||
case 'select':
|
case 'select':
|
||||||
return "SELECT {$fields} FROM {$table} {$alias} {$joins} {$conditions} {$order} {$limit}";
|
return "SELECT {$fields} FROM {$table} {$alias} {$joins} {$conditions} {$order} {$limit}";
|
||||||
break;
|
break;
|
||||||
|
case 'create':
|
||||||
|
return "INSERT INTO {$table} ({$fields}) VALUES ({$values})";
|
||||||
|
break;
|
||||||
case 'update':
|
case 'update':
|
||||||
if (!empty($alias)) {
|
if (!empty($alias)) {
|
||||||
$aliases = "{$this->alias}{$alias} ";
|
$aliases = "{$this->alias}{$alias} ";
|
||||||
|
@ -916,6 +919,19 @@ class DboOracle extends DboSource {
|
||||||
}
|
}
|
||||||
return "DELETE FROM {$table} {$aliases}{$conditions}";
|
return "DELETE FROM {$table} {$aliases}{$conditions}";
|
||||||
break;
|
break;
|
||||||
|
case 'schema':
|
||||||
|
foreach (array('columns', 'indexes') as $var) {
|
||||||
|
if (is_array(${$var})) {
|
||||||
|
${$var} = "\t" . join(",\n\t", array_filter(${$var}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (trim($indexes) != '') {
|
||||||
|
$columns .= ',';
|
||||||
|
}
|
||||||
|
return "CREATE TABLE {$table} (\n{$columns}{$indexes})";
|
||||||
|
break;
|
||||||
|
case 'alter':
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -1076,5 +1092,27 @@ class DboOracle extends DboSource {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Generate a "drop table" statement for the given Schema object
|
||||||
|
*
|
||||||
|
* @param object $schema An instance of a subclass of CakeSchema
|
||||||
|
* @param string $table Optional. If specified only the table name given will be generated.
|
||||||
|
* Otherwise, all tables defined in the schema are generated.
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function dropSchema($schema, $table = null) {
|
||||||
|
if (!is_a($schema, 'CakeSchema')) {
|
||||||
|
trigger_error(__('Invalid schema object', true), E_USER_WARNING);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
$out = '';
|
||||||
|
|
||||||
|
foreach ($schema->tables as $curTable => $columns) {
|
||||||
|
if (!$table || $table == $curTable) {
|
||||||
|
$out .= 'DROP TABLE ' . $this->fullTableName($curTable) . "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -36,6 +36,10 @@ require_once LIBS . 'model' . DS . 'datasources' . DS . 'dbo' . DS . 'dbo_oracle
|
||||||
* @subpackage cake.tests.cases.libs.model.datasources.dbo
|
* @subpackage cake.tests.cases.libs.model.datasources.dbo
|
||||||
*/
|
*/
|
||||||
class DboOracleTest extends CakeTestCase {
|
class DboOracleTest extends CakeTestCase {
|
||||||
|
/**
|
||||||
|
* fixtures property
|
||||||
|
*/
|
||||||
|
var $fixtures = array('core.oracle_user');
|
||||||
/**
|
/**
|
||||||
* setup method
|
* setup method
|
||||||
*
|
*
|
||||||
|
@ -86,11 +90,14 @@ class DboOracleTest extends CakeTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
$config = $this->db->config;
|
$config = $this->db->config;
|
||||||
|
$old_pw = $this->db->config['password'];
|
||||||
$this->db->config['password'] = 'keepmeout';
|
$this->db->config['password'] = 'keepmeout';
|
||||||
$this->db->connect();
|
$this->db->connect();
|
||||||
$e = $this->db->lastError();
|
$e = $this->db->lastError();
|
||||||
$r = 'ORA-01017: invalid username/password; logon denied';
|
$r = 'ORA-01017: invalid username/password; logon denied';
|
||||||
$this->assertEqual($e, $r);
|
$this->assertEqual($e, $r);
|
||||||
|
$this->db->config['password'] = $old_pw;
|
||||||
|
$this->db->connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -124,6 +131,10 @@ class DboOracleTest extends CakeTestCase {
|
||||||
$this->assertEqual($e, $r);
|
$this->assertEqual($e, $r);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
Loading…
Add table
Reference in a new issue