mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
fixes #4238, Mysqli working with the test suite.
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6849 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
c0f042e4ab
commit
99874c60d9
4 changed files with 63 additions and 48 deletions
|
@ -599,32 +599,5 @@ class DboMysql extends DboSource {
|
||||||
}
|
}
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Format indexes for create table
|
|
||||||
*
|
|
||||||
* @param array $indexes
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
function buildIndex($indexes) {
|
|
||||||
$join = array();
|
|
||||||
foreach ($indexes as $name => $value) {
|
|
||||||
$out = '';
|
|
||||||
if ($name == 'PRIMARY') {
|
|
||||||
$out .= 'PRIMARY ';
|
|
||||||
$name = null;
|
|
||||||
} else {
|
|
||||||
if (!empty($value['unique'])) {
|
|
||||||
$out .= 'UNIQUE ';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (is_array($value['column'])) {
|
|
||||||
$out .= 'KEY '. $name .' (' . join(', ', array_map(array(&$this, 'name'), $value['column'])) . ')';
|
|
||||||
} else {
|
|
||||||
$out .= 'KEY '. $name .' (' . $this->name($value['column']) . ')';
|
|
||||||
}
|
|
||||||
$join[] = $out;
|
|
||||||
}
|
|
||||||
return join(",\n\t", $join);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -54,6 +54,13 @@ class DboMysqli extends DboSource {
|
||||||
* @var unknown_type
|
* @var unknown_type
|
||||||
*/
|
*/
|
||||||
var $endQuote = "`";
|
var $endQuote = "`";
|
||||||
|
/**
|
||||||
|
* index definition, standard cake, primary, index, unique
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
var $index = array('PRI' => 'primary', 'MUL' => 'index', 'UNI' => 'unique');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base configuration settings for Mysqli driver
|
* Base configuration settings for Mysqli driver
|
||||||
*
|
*
|
||||||
|
@ -199,6 +206,9 @@ class DboMysqli extends DboSource {
|
||||||
'default' => $column[0]['Default'],
|
'default' => $column[0]['Default'],
|
||||||
'length' => $this->length($column[0]['Type'])
|
'length' => $this->length($column[0]['Type'])
|
||||||
);
|
);
|
||||||
|
if(!empty($column[0]['Key']) && isset($this->index[$column[0]['Key']])) {
|
||||||
|
$fields[$column[0]['Field']]['key'] = $this->index[$column[0]['Key']];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -979,17 +979,19 @@ class DboSource extends DataSource {
|
||||||
unset($assocFields, $passedFields);
|
unset($assocFields, $passedFields);
|
||||||
}
|
}
|
||||||
|
|
||||||
// $tmpModel =& $model;
|
/* Saving for later refactor
|
||||||
//
|
$tmpModel =& $model;
|
||||||
// if ($linkModel != null) {
|
|
||||||
// $tmpModel =& $linkModel;
|
if ($linkModel != null) {
|
||||||
// }
|
$tmpModel =& $linkModel;
|
||||||
// foreach ($tmpModel->schema() as $field => $info) {
|
}
|
||||||
// if ($info['type'] == 'boolean') {
|
foreach ($tmpModel->schema() as $field => $info) {
|
||||||
// $this->_booleans[$tmpModel->alias][] = $field;
|
if ($info['type'] == 'boolean') {
|
||||||
// }
|
$this->_booleans[$tmpModel->alias][] = $field;
|
||||||
// }
|
}
|
||||||
// unset($tmpModel);
|
}
|
||||||
|
unset($tmpModel);
|
||||||
|
*/
|
||||||
|
|
||||||
if ($linkModel == null) {
|
if ($linkModel == null) {
|
||||||
return $this->buildStatement(
|
return $this->buildStatement(
|
||||||
|
@ -1984,9 +1986,7 @@ class DboSource extends DataSource {
|
||||||
* @access protected
|
* @access protected
|
||||||
*/
|
*/
|
||||||
function insertMulti($table, $fields, $values) {
|
function insertMulti($table, $fields, $values) {
|
||||||
if (is_object($table)) {
|
$table = $this->fullTableName($table);
|
||||||
$table = $this->fullTableName($table);
|
|
||||||
}
|
|
||||||
if (is_array($fields)) {
|
if (is_array($fields)) {
|
||||||
$fields = join(', ', array_map(array(&$this, 'name'), $fields));
|
$fields = join(', ', array_map(array(&$this, 'name'), $fields));
|
||||||
}
|
}
|
||||||
|
@ -2139,8 +2139,25 @@ class DboSource extends DataSource {
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function buildIndex($indexes) {
|
function buildIndex($indexes) {
|
||||||
return false;
|
$join = array();
|
||||||
|
foreach ($indexes as $name => $value) {
|
||||||
|
$out = '';
|
||||||
|
if ($name == 'PRIMARY') {
|
||||||
|
$out .= 'PRIMARY ';
|
||||||
|
$name = null;
|
||||||
|
} else {
|
||||||
|
if (!empty($value['unique'])) {
|
||||||
|
$out .= 'UNIQUE ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (is_array($value['column'])) {
|
||||||
|
$out .= 'KEY '. $name .' (' . join(', ', array_map(array(&$this, 'name'), $value['column'])) . ')';
|
||||||
|
} else {
|
||||||
|
$out .= 'KEY '. $name .' (' . $this->name($value['column']) . ')';
|
||||||
|
}
|
||||||
|
$join[] = $out;
|
||||||
|
}
|
||||||
|
return join(",\n\t", $join);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -33,7 +33,19 @@
|
||||||
* @subpackage cake.cake.tests.lib
|
* @subpackage cake.cake.tests.lib
|
||||||
*/
|
*/
|
||||||
class CakeTestFixture extends Object {
|
class CakeTestFixture extends Object {
|
||||||
|
/**
|
||||||
|
* Cake's DBO driver (e.g: DboMysql).
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
var $db = null;
|
var $db = null;
|
||||||
|
/**
|
||||||
|
* Full Table Name
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
var $table = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiate the fixture.
|
* Instantiate the fixture.
|
||||||
*
|
*
|
||||||
|
@ -42,15 +54,17 @@ class CakeTestFixture extends Object {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function __construct(&$db) {
|
function __construct(&$db) {
|
||||||
$this->init();
|
App::import('Model', 'Schema');
|
||||||
if(!class_exists('cakeschema')) {
|
|
||||||
uses('model' . DS .'schema');
|
|
||||||
}
|
|
||||||
$this->Schema = new CakeSchema(array('name'=>'TestSuite', 'connection'=>'test_suite'));
|
$this->Schema = new CakeSchema(array('name'=>'TestSuite', 'connection'=>'test_suite'));
|
||||||
|
|
||||||
|
$this->init();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Initialize the fixture.
|
* Initialize the fixture.
|
||||||
*
|
*
|
||||||
|
* @param object Cake's DBO driver (e.g: DboMysql).
|
||||||
|
* @access public
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
function init() {
|
function init() {
|
||||||
if (isset($this->import) && (is_string($this->import) || is_array($this->import))) {
|
if (isset($this->import) && (is_string($this->import) || is_array($this->import))) {
|
||||||
|
@ -105,6 +119,7 @@ class CakeTestFixture extends Object {
|
||||||
if (!isset($this->table)) {
|
if (!isset($this->table)) {
|
||||||
$this->table = Inflector::underscore(Inflector::pluralize($this->name));
|
$this->table = Inflector::underscore(Inflector::pluralize($this->name));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($this->primaryKey) && isset($this->fields['id'])) {
|
if (!isset($this->primaryKey) && isset($this->fields['id'])) {
|
||||||
$this->primaryKey = 'id';
|
$this->primaryKey = 'id';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue