当前位置: 首页>>代码示例>>PHP>>正文


PHP Sqlite::listSources方法代码示例

本文整理汇总了PHP中Sqlite::listSources方法的典型用法代码示例。如果您正苦于以下问题:PHP Sqlite::listSources方法的具体用法?PHP Sqlite::listSources怎么用?PHP Sqlite::listSources使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sqlite的用法示例。


在下文中一共展示了Sqlite::listSources方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testCacheKeyName

 /**
  * Tests that cached table descriptions are saved under the sanitized key name
  *
  * @return void
  */
 public function testCacheKeyName()
 {
     Configure::write('Cache.disable', false);
     $dbName = 'db' . rand() . '$(*%&).db';
     $this->assertFalse(file_exists(TMP . $dbName));
     try {
         $db = new Sqlite(array_merge($this->Dbo->config, array('database' => TMP . $dbName)));
     } catch (MissingConnectionException $e) {
         // This might be caused by NTFS file systems, where '*' is a forbidden character. Repeat without this character.
         $dbName = str_replace('*', '', $dbName);
         $db = new Sqlite(array_merge($this->Dbo->config, array('database' => TMP . $dbName)));
     }
     $this->assertTrue(file_exists(TMP . $dbName));
     $db->execute("CREATE TABLE test_list (id VARCHAR(255));");
     $db->cacheSources = true;
     $this->assertEquals(array('test_list'), $db->listSources());
     $db->cacheSources = false;
     $fileName = '_' . preg_replace('/[^A-Za-z0-9_\\-+]/', '_', TMP . $dbName) . '_list';
     $result = Cache::read($fileName, '_cake_model_');
     $this->assertEquals(array('test_list'), $result);
     Cache::delete($fileName, '_cake_model_');
     Configure::write('Cache.disable', true);
 }
开发者ID:mgoo,项目名称:MovieServer,代码行数:28,代码来源:SqliteTest.php

示例2: testCacheKeyName

 /**
  * Tests that cached table descriptions are saved under the sanitized key name
  *
  * @return void
  */
 public function testCacheKeyName()
 {
     Configure::write('Cache.disable', false);
     $dbName = 'db' . rand() . '$(*%&).db';
     $this->assertFalse(file_exists(TMP . $dbName));
     $db = new Sqlite(array_merge($this->Dbo->config, array('database' => TMP . $dbName)));
     $this->assertTrue(file_exists(TMP . $dbName));
     $db->execute("CREATE TABLE test_list (id VARCHAR(255));");
     $db->cacheSources = true;
     $this->assertEquals(array('test_list'), $db->listSources());
     $db->cacheSources = false;
     $fileName = '_' . preg_replace('/[^A-Za-z0-9_\\-+]/', '_', TMP . $dbName) . '_list';
     $result = Cache::read($fileName, '_cake_model_');
     $this->assertEquals(array('test_list'), $result);
     Cache::delete($fileName, '_cake_model_');
     Configure::write('Cache.disable', true);
 }
开发者ID:saihe,项目名称:reservation,代码行数:22,代码来源:SqliteTest.php

示例3: 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
  */
 public function listSources($data = null)
 {
     //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 ";
     $result = $this->fetchAll("SELECT name FROM sqlite_master WHERE type='table' AND name<>'sqlite_sequence' ORDER BY name;", false);
     //pr($result);
     if (!$result || empty($result)) {
         // 接続をフルパスに戻す
         $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:naow9y,项目名称:basercms,代码行数:38,代码来源:BcSqlite.php


注:本文中的Sqlite::listSources方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。