mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 11:06:15 +00:00
Fixing notice error caused when looking for info on tables that don't exist.
This commit is contained in:
parent
e0420937a7
commit
26c5f78a14
2 changed files with 19 additions and 1 deletions
|
@ -298,6 +298,9 @@ class DboMysql extends DboSource {
|
|||
}
|
||||
$fields = false;
|
||||
$cols = $this->_execute('SHOW FULL COLUMNS FROM ' . $this->fullTableName($model));
|
||||
if (!$cols) {
|
||||
throw new CakeException(__('Could not describe table for %s', $model->name));
|
||||
}
|
||||
|
||||
foreach ($cols as $column) {
|
||||
$fields[$column->Field] = array(
|
||||
|
@ -609,7 +612,7 @@ class DboMysql extends DboSource {
|
|||
}
|
||||
}
|
||||
$result->closeCursor();
|
||||
if (is_string($name)) {
|
||||
if (is_string($name) && isset($tables[$name])) {
|
||||
return $tables[$name];
|
||||
}
|
||||
return $tables;
|
||||
|
|
|
@ -795,6 +795,21 @@ class DboMysqlTest extends CakeTestCase {
|
|||
$this->assertEqual($tables, array('cake_table', 'another_table'));
|
||||
}
|
||||
|
||||
/**
|
||||
* test that listDetailedSources with a named table that doesn't exist.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testListDetailedSourcesNamed() {
|
||||
$this->loadFixtures('Apple');
|
||||
|
||||
$result = $this->Dbo->listDetailedSources('imaginary');
|
||||
$this->assertEquals(array(), $result, 'Should be empty when table does not exist.');
|
||||
|
||||
$result = $this->Dbo->listDetailedSources();
|
||||
$this->assertTrue(isset($result['apples']), 'Key should exist');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that getVersion method sends the correct query for getting the mysql version
|
||||
* @return void
|
||||
|
|
Loading…
Add table
Reference in a new issue