當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DboSource::listSources方法代碼示例

本文整理匯總了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));
 }
開發者ID:superstarrajini,項目名稱:cakepackages,代碼行數:32,代碼來源:PrecheckConditionTest.php

示例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()));
 }
開發者ID:saihe,項目名稱:reservation,代碼行數:14,代碼來源:SqliteTest.php

示例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;
 }
開發者ID:alescx,項目名稱:forum,代碼行數:25,代碼來源:InstallShell.php

示例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;
 }
開發者ID:christianallred,項目名稱:fluent_univ,代碼行數:22,代碼來源:dbo_db2.php

示例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;
     }
 }
開發者ID:nojimage,項目名稱:basercms,代碼行數:26,代碼來源:dbo_csv.php

示例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;
     }
 }
開發者ID:hikmanet,項目名稱:HnsAutomobiles,代碼行數:24,代碼來源:dbo_oci.php

示例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;
     }
 }
開發者ID:xplico,項目名稱:xplico,代碼行數:23,代碼來源:dbo_sqlsrv.php

示例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;
     }
 }
開發者ID:quinns,項目名稱:REST-API,代碼行數:23,代碼來源:dbo_sybase.php

示例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;
     }
 }
開發者ID:Nervie,項目名稱:Beta,代碼行數:25,代碼來源:Sqlserver.php

示例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;
     }
 }
開發者ID:MrGrigorev,項目名稱:reserva-de-salas,代碼行數:27,代碼來源:Postgres.php

示例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();
 }
開發者ID:nazo,項目名稱:phpcondo,代碼行數:45,代碼來源:dbo_sqlite3.php

示例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;
 }
開發者ID:byu-oit-appdev,項目名稱:student-ratings,代碼行數:31,代碼來源:Oracle.php

示例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;
 }
開發者ID:alphp,項目名稱:Oracle-cake2,代碼行數:24,代碼來源:Oracle.php

示例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));
 }
開發者ID:tetsuo111,項目名稱:cakephp,代碼行數:13,代碼來源:CakeMigrationTest.php

示例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;
     }
 }
開發者ID:nriccitelli,項目名稱:CakePHP-sqlsrv-driver,代碼行數:29,代碼來源:dbo_sqlsrv.php


注:本文中的DboSource::listSources方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。