mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 11:06:15 +00:00
fixes #4987, unable to delete by adding version compare and setting useAlias in DboMysql
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7268 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
a34c3a85de
commit
e70f45e1d6
1 changed files with 15 additions and 0 deletions
|
@ -97,6 +97,12 @@ class DboMysql extends DboSource {
|
||||||
'binary' => array('name' => 'blob'),
|
'binary' => array('name' => 'blob'),
|
||||||
'boolean' => array('name' => 'tinyint', 'limit' => '1')
|
'boolean' => array('name' => 'tinyint', 'limit' => '1')
|
||||||
);
|
);
|
||||||
|
/**
|
||||||
|
* use alias for update and delete. Set to true if version >= 4.1
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
var $__useAlias = true;
|
||||||
/**
|
/**
|
||||||
* Connects to the database using options in the given configuration array.
|
* Connects to the database using options in the given configuration array.
|
||||||
*
|
*
|
||||||
|
@ -121,6 +127,8 @@ class DboMysql extends DboSource {
|
||||||
$this->setEncoding($config['encoding']);
|
$this->setEncoding($config['encoding']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->__useAlias = (bool)version_compare(mysql_get_server_info($this->connection), "4.1", ">=");
|
||||||
|
|
||||||
return $this->connected;
|
return $this->connected;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -251,6 +259,10 @@ class DboMysql extends DboSource {
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function update(&$model, $fields = array(), $values = null, $conditions = null) {
|
function update(&$model, $fields = array(), $values = null, $conditions = null) {
|
||||||
|
if (!$this->__useAlias) {
|
||||||
|
return parent::update(&$model, $fields, $values, $conditions);
|
||||||
|
}
|
||||||
|
|
||||||
if ($values == null) {
|
if ($values == null) {
|
||||||
$combined = $fields;
|
$combined = $fields;
|
||||||
} else {
|
} else {
|
||||||
|
@ -286,6 +298,9 @@ class DboMysql extends DboSource {
|
||||||
* @return boolean Success
|
* @return boolean Success
|
||||||
*/
|
*/
|
||||||
function delete(&$model, $conditions = null) {
|
function delete(&$model, $conditions = null) {
|
||||||
|
if (!$this->__useAlias) {
|
||||||
|
return parent::delete(&$model, $conditions);
|
||||||
|
}
|
||||||
$alias = $this->name($model->alias);
|
$alias = $this->name($model->alias);
|
||||||
$table = $this->fullTableName($model);
|
$table = $this->fullTableName($model);
|
||||||
$joins = implode(' ', $this->_getJoins($model));
|
$joins = implode(' ', $this->_getJoins($model));
|
||||||
|
|
Loading…
Add table
Reference in a new issue