本文整理匯總了PHP中DboSource::listSources方法的典型用法代碼示例。如果您正苦於以下問題:PHP DboSource::listSources方法的具體用法?PHP DboSource::listSources怎麽用?PHP DboSource::listSources使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DboSource
的用法示例。
在下文中一共展示了DboSource::listSources方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testRenameTable
/**
* TestRenameTable method
*
* @return void
*/
public function testRenameTable()
{
$this->loadFixtures('User', 'Post');
$Migration = new TestPrecheckCakeMigration(array('up' => array('rename_table' => array('posts' => 'renamed_posts')), 'down' => array('rename_table' => array('renamed_posts' => 'posts')), 'precheck' => 'Migrations.PrecheckCondition'));
$Migration->initDb();
$this->assertTrue($Migration->Precheck->beforeAction($Migration, 'rename_table', array('old_name' => $this->db->fullTableName('posts', false, false), 'new_name' => $this->db->fullTableName('renamed_posts', false, false))));
$sources = $this->db->listSources();
$this->assertTrue(in_array($this->db->fullTableName('posts', false, false), $sources));
$this->assertFalse(in_array($this->db->fullTableName('renamed_posts', false, false), $sources));
$this->assertTrue($Migration->run('up'));
$sources = $this->db->listSources();
$this->assertFalse(in_array($this->db->fullTableName('posts', false, false), $sources));
$this->assertTrue(in_array($this->db->fullTableName('renamed_posts', false, false), $sources));
$this->assertFalse($Migration->Precheck->beforeAction($Migration, 'rename_table', array('old_name' => $this->db->fullTableName('posts', false, false), 'new_name' => $this->db->fullTableName('renamed_posts', false, false))));
$this->assertTrue($Migration->Precheck->beforeAction($Migration, 'rename_table', array('old_name' => $this->db->fullTableName('renamed_posts', false, false), 'new_name' => $this->db->fullTableName('posts', false, false))));
try {
$Migration->run('up');
} catch (MigrationException $e) {
$this->fail('Exception triggered: ' . $e->getMessage());
}
$this->assertTrue($Migration->run('down'));
$this->assertFalse($Migration->Precheck->beforeAction($Migration, 'rename_table', array('old_name' => $this->db->fullTableName('renamed_posts', false, false), 'new_name' => $this->db->fullTableName('posts', false, false))));
$this->assertTrue($Migration->Precheck->beforeAction($Migration, 'rename_table', array('old_name' => $this->db->fullTableName('posts', false, false), 'new_name' => $this->db->fullTableName('renamed_posts', false, false))));
$sources = $this->db->listSources();
$this->assertTrue(in_array($this->db->fullTableName('posts', false, false), $sources));
$this->assertFalse(in_array($this->db->fullTableName('renamed_posts', false, false), $sources));
}
示例2: testTableListCacheDisabling
/**
* Tests that SELECT queries from DboSqlite::listSources() are not cached
*
* @return void
*/
public function testTableListCacheDisabling()
{
$this->assertFalse(in_array('foo_test', $this->Dbo->listSources()));
$this->Dbo->query('CREATE TABLE foo_test (test VARCHAR(255))');
$this->assertTrue(in_array('foo_test', $this->Dbo->listSources()));
$this->Dbo->cacheSources = false;
$this->Dbo->query('DROP TABLE foo_test');
$this->assertFalse(in_array('foo_test', $this->Dbo->listSources()));
}
示例3: checkStatus
/**
* Check the database status before installation.
*
* @return bool
*/
public function checkStatus()
{
if (!$this->db->isConnected()) {
$this->out(sprintf('<error>Database connection for %s failed!</error>', FORUM_DATABASE));
return false;
}
// Check the required tables
$tables = $this->db->listSources();
$checkFor = array($this->install['table'], 'aros', 'acos', 'aros_acos');
$this->out(sprintf('The following tables are required: %s', implode(', ', $checkFor)));
$this->out('<info>Checking tables...</info>');
foreach ($checkFor as $table) {
if (!in_array($table, $tables)) {
$this->out(sprintf('<error>No %s table was found in %s</error>', $table, FORUM_DATABASE));
return false;
}
}
$this->out('<info>Installation status good, proceeding...</info>');
return true;
}
示例4: listSources
/**
* Returns an array of all the tables in the database.
* Should call parent::listSources twice in the method:
* once to see if the list is cached, and once to cache
* the list if not.
*
* @return array Array of tablenames in the database
*/
function listSources()
{
$cache = parent::listSources();
if ($cache != null) {
return $cache;
}
$result = db2_tables($this->connection);
$tables = array();
while (db2_fetch_row($result)) {
$tables[] = strtolower(db2_result($result, 'TABLE_NAME'));
}
parent::listSources($tables);
return $tables;
}
示例5: listSources
/**
* テーブルの全てのリストを取得する
*
* @return array Array of tablenames in the database
*/
function listSources()
{
$cache = parent::listSources();
if ($cache != null) {
return $cache;
}
$folder = new Folder($this->config['database']);
$result = $folder->read(true, true);
if (empty($result[1])) {
return array();
} else {
$tables = array();
foreach ($result[1] as $csv) {
if (preg_match('/^' . $this->config['prefix'] . '[a-z0-9]/', $csv)) {
$tables[] = str_replace('.csv', '', $csv);
}
}
parent::listSources($tables);
return $tables;
}
}
示例6: listSources
/**
* Returns an array of sources (tables) in the database.
*
* @return array Array of tablenames in the database
*/
function listSources()
{
$cache = parent::listSources();
if ($cache != null) {
return $cache;
}
$stmt = oci_parse($this->connection, "select * from tab");
$res = oci_execute($stmt, OCI_DEFAULT);
if (!$res) {
return array();
} else {
$tables = array();
while (oci_fetch($stmt)) {
$tables[] = strtolower(oci_result($stmt, "TNAME"));
}
parent::listSources($tables);
return $tables;
}
}
示例7: listSources
/**
* Returns an array of sources (tables) in the database.
*
* @return array Array of tablenames in the database
*/
function listSources()
{
$cache = parent::listSources();
if ($cache != null) {
return $cache;
}
$result = $this->fetchAll('SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES', false);
if (!$result || empty($result)) {
return array();
} else {
$tables = array();
foreach ($result as $table) {
$tables[] = $table[0]['TABLE_NAME'];
}
parent::listSources($tables);
return $tables;
}
}
示例8: listSources
/**
* Returns an array of sources (tables) in the database.
*
* @return array Array of tablenames in the database
*/
function listSources()
{
$cache = parent::listSources();
if ($cache != null) {
return $cache;
}
$result = $this->_execute("select name from sysobjects where type='U'");
if (!$result) {
return array();
} else {
$tables = array();
while ($line = sybase_fetch_array($result)) {
$tables[] = $line[0];
}
parent::listSources($tables);
return $tables;
}
}
示例9: listSources
/**
* Returns an array of sources (tables) in the database.
*
* @return array Array of tablenames in the database
*/
public function listSources()
{
$cache = parent::listSources();
if ($cache !== null) {
return $cache;
}
$result = $this->_execute("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE TABLE'");
if (!$result) {
$result->closeCursor();
return array();
} else {
$tables = array();
while ($line = $result->fetch()) {
$tables[] = $line[0];
}
$result->closeCursor();
parent::listSources($tables);
return $tables;
}
}
示例10: listSources
/**
* Returns an array of tables in the database. If there are no tables, an error is raised and the application exits.
*
* @param mixed $data
* @return array Array of table names in the database
*/
public function listSources($data = null)
{
$cache = parent::listSources();
if ($cache != null) {
return $cache;
}
$schema = $this->config['schema'];
$sql = "SELECT table_name as name FROM INFORMATION_SCHEMA.tables WHERE table_schema = ?";
$result = $this->_execute($sql, array($schema));
if (!$result) {
return array();
} else {
$tables = array();
foreach ($result as $item) {
$tables[] = $item->name;
}
$result->closeCursor();
parent::listSources($tables);
return $tables;
}
}
示例11: listSources
/**
* Returns an array of tables in the database. If there are no tables, an error is raised and the application exits.
*
* @return array Array of tablenames in the database
* @access public
*/
function listSources()
{
//echo "runs listSources\n";
$db = $this->config['database'];
$this->config['database'] = basename($this->config['database']);
$cache = parent::listSources();
if ($cache != null) {
// >>> ADD 2010/03/19 egashira
// 接続をフルパスに戻す
$this->config['database'] = $db;
// <<<
return $cache;
}
//echo "listsources:beforeresult ";
// >>> CUSTOMIZE MODIFY 2010/12/26 ryuring
//$result = $this->fetchAll("SELECT name FROM sqlite_master WHERE type='table' ORDER BY name;", false);
// ---
$result = $this->fetchAll("SELECT name FROM sqlite_master WHERE type='table' AND name<>'sqlite_sequence' ORDER BY name;", false);
// <<<
//echo "listsources:result ";
//pr($result);
if (!$result || empty($result)) {
// >>> ADD 2010/03/19 egashira
// 接続をフルパスに戻す
$this->config['database'] = $db;
// <<<
return array();
} else {
$tables = array();
foreach ($result as $table) {
$tables[] = $table[0]['name'];
}
parent::listSources($tables);
$this->config['database'] = $db;
return $tables;
}
$this->config['database'] = $db;
return array();
}
示例12: listSources
/**
* Returns an array of tables in the database. If there are no tables, an error is
* raised and the application exits.
*
* @return array tablenames in the database
* @access public
*/
function listSources($data = null)
{
$cache = parent::listSources();
if ($cache != null) {
return $cache;
}
$ownerClause = '';
$sql = "SELECT owner, view_name AS name FROM all_views {$ownerClause} UNION SELECT owner, table_name AS name FROM all_tables {$ownerClause} ORDER BY 1, 2";
if (!$this->execute($sql)) {
return false;
}
$sources = array();
if (!empty($this->config['prefix'])) {
while ($r = $this->fetchRow()) {
$sources[] = strtolower($r[0]['owner'] . '.' . $r[0]['name']);
}
} else {
while ($r = $this->fetchRow()) {
$sources[] = strtolower($r[0]['name']);
}
}
parent::listSources($sources);
return $sources;
}
示例13: listSources
/**
* Returns an array of tables in the database. If there are no tables, an error is
* raised and the application exits.
*
* @return array tablenames in the database
* @access public
*/
function listSources($data = null)
{
$cache = parent::listSources();
if ($cache != null) {
return $cache;
}
$sql = 'SELECT view_name AS name FROM all_views' . ($this->_defaultSchema ? ' WHERE owner = \'' . $this->_defaultSchema . '\'' : '') . ' UNION SELECT table_name AS name FROM all_tables' . ($this->_defaultSchema ? ' WHERE owner = \'' . $this->_defaultSchema . '\'' : '');
if (!$this->execute($sql)) {
return false;
}
$sources = array();
while ($r = $this->fetchRow()) {
$sources[] = strtolower($r[0]['name']);
}
parent::listSources($sources);
return $sources;
}
示例14: testTruncateLongIndexKey
public function testTruncateLongIndexKey()
{
$migration = new TestCakeMigration(array('up' => array('create_table' => array('migration_categories' => array('id' => array('type' => 'string', 'length ' => 36, 'null' => false, 'key' => 'primary'), 'description' => array('type' => 'string', 'null' => false, 'length' => 256, 'default' => null), 'info' => array('type' => 'string', 'length' => 256, 'null' => false, 'default' => null), 'indexes' => array('TESTING_INDEX' => array('column' => array('description', 'info'), 'unique' => 1))))), 'down' => array('drop_table' => array('migration_categories'))));
$sources = $this->db->listSources();
$this->assertFalse(in_array($this->db->fullTableName('migration_categories', false, false), $sources));
try {
$migration->run('up');
$this->fail('No exception triggered');
} catch (MigrationException $e) {
$this->assertPattern('/SQL Error/', $e->getMessage());
}
$this->assertFalse(in_array($this->db->fullTableName('migration_categories', false, false), $sources));
}
示例15: listSources
/**
* Returns an array of sources (tables) in the database.
*
* @return array Array of tablenames in the database
*/
function listSources()
{
$cache = parent::listSources();
if ($cache != null) {
return $cache;
}
$result = $this->fetchAll('SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES', false);
$syn = $this->fetchAll('select SUBSTRING(base_object_name,2,LEN(base_object_name)-2) as object,name as TABLE_NAME from sys.synonyms', false);
if (!$result || empty($result)) {
return array();
} else {
$tables = array();
foreach ($result as $table) {
$tables[] = $table[0]['TABLE_NAME'];
}
foreach ($syn as $table) {
// $tables[] = $table[0]['TABLE_NAME'];
$this->synonyms[$table[0]['TABLE_NAME']] = $table[0]['object'];
}
// debug($this->synonyms);
parent::listSources($tables);
return $tables;
}
}