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:
gwoo 2008-05-13 18:03:44 +00:00
parent c0f042e4ab
commit 99874c60d9
4 changed files with 63 additions and 48 deletions

View file

@ -599,32 +599,5 @@ class DboMysql extends DboSource {
}
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);
}
}
?>

View file

@ -54,6 +54,13 @@ class DboMysqli extends DboSource {
* @var unknown_type
*/
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
*
@ -199,6 +206,9 @@ class DboMysqli extends DboSource {
'default' => $column[0]['Default'],
'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']];
}
}
}

View file

@ -181,7 +181,7 @@ class DboSource extends DataSource {
$limit = null;
$page = null;
$recursive = null;
if (count($args) == 1) {
return $this->fetchAll($args[0]);
@ -979,17 +979,19 @@ class DboSource extends DataSource {
unset($assocFields, $passedFields);
}
// $tmpModel =& $model;
//
// if ($linkModel != null) {
// $tmpModel =& $linkModel;
// }
// foreach ($tmpModel->schema() as $field => $info) {
// if ($info['type'] == 'boolean') {
// $this->_booleans[$tmpModel->alias][] = $field;
// }
// }
// unset($tmpModel);
/* Saving for later refactor
$tmpModel =& $model;
if ($linkModel != null) {
$tmpModel =& $linkModel;
}
foreach ($tmpModel->schema() as $field => $info) {
if ($info['type'] == 'boolean') {
$this->_booleans[$tmpModel->alias][] = $field;
}
}
unset($tmpModel);
*/
if ($linkModel == null) {
return $this->buildStatement(
@ -1984,9 +1986,7 @@ class DboSource extends DataSource {
* @access protected
*/
function insertMulti($table, $fields, $values) {
if (is_object($table)) {
$table = $this->fullTableName($table);
}
$table = $this->fullTableName($table);
if (is_array($fields)) {
$fields = join(', ', array_map(array(&$this, 'name'), $fields));
}
@ -2139,8 +2139,25 @@ class DboSource extends DataSource {
* @return string
*/
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);
}
}
?>

View file

@ -33,7 +33,19 @@
* @subpackage cake.cake.tests.lib
*/
class CakeTestFixture extends Object {
/**
* Cake's DBO driver (e.g: DboMysql).
*
* @access public
*/
var $db = null;
/**
* Full Table Name
*
* @access public
*/
var $table = null;
/**
* Instantiate the fixture.
*
@ -42,15 +54,17 @@ class CakeTestFixture extends Object {
* @access public
*/
function __construct(&$db) {
$this->init();
if(!class_exists('cakeschema')) {
uses('model' . DS .'schema');
}
App::import('Model', 'Schema');
$this->Schema = new CakeSchema(array('name'=>'TestSuite', 'connection'=>'test_suite'));
$this->init();
}
/**
* Initialize the fixture.
*
* @param object Cake's DBO driver (e.g: DboMysql).
* @access public
*
*/
function init() {
if (isset($this->import) && (is_string($this->import) || is_array($this->import))) {
@ -105,6 +119,7 @@ class CakeTestFixture extends Object {
if (!isset($this->table)) {
$this->table = Inflector::underscore(Inflector::pluralize($this->name));
}
if (!isset($this->primaryKey) && isset($this->fields['id'])) {
$this->primaryKey = 'id';
}