示例#1
0
 public function testLoad()
 {
     CM_Config::get()->Foo = new stdClass();
     CM_Config::get()->Foo->types = [1111 => 'Foo1', 2222 => 'Foo2'];
     CM_Config::get()->Bar = new stdClass();
     CM_Config::get()->Bar->types = [3333 => 'Bar1', 4444 => 'Bar2'];
     $dumper = new CM_Class_TypeDumper($this->getServiceManager());
     $dumper->load(new CM_OutputStream_Null());
     $rowList = [['type' => 1111, 'className' => 'Foo1'], ['type' => 2222, 'className' => 'Foo2'], ['type' => 3333, 'className' => 'Bar1'], ['type' => 4444, 'className' => 'Bar2']];
     $dbClient = $this->getServiceManager()->getDatabases()->getMaster();
     foreach ($rowList as $row) {
         $queryCount = new CM_Db_Query_Count($dbClient, 'cm_tmp_classType', $row);
         $this->assertSame('1', $queryCount->execute()->fetchColumn());
     }
 }
示例#2
0
 public function testAll()
 {
     $query = new CM_Db_Query_Count(self::$_client, 't`est', array('foo' => 'foo1', 'bar' => 'bar1'));
     $this->assertSame('SELECT COUNT(*) FROM `t``est` WHERE `foo` = ? AND `bar` = ?', $query->getSqlTemplate());
     $this->assertEquals(array('foo1', 'bar1'), $query->getParameters());
 }
示例#3
0
文件: Db.php 项目: NicolasSchmutz/cm
 /**
  * @param string            $table
  * @param string|array|null $where Associative array field=>value OR string
  * @return int
  */
 public static function count($table, $where = null)
 {
     $client = self::getClient();
     $query = new CM_Db_Query_Count($client, $table, $where);
     return (int) $query->execute()->fetchColumn();
 }