Exemple #1
0
 public function testExoticSQLLiteActions()
 {
     $config = new Config();
     $config->setUsername('user');
     $config->setDsn('sqlite::memory:');
     $sqliteDb = new Database($config);
     $sqliteDb->addActionAfterConnect(function (PDO $pdo) {
         $pdo->sqliteCreateFunction('md5rev', function ($string) {
             return strrev(md5($string));
         }, 1);
     });
     $sqliteDb->run(self::$createSQL);
     $row = $sqliteDb->query("SELECT username, md5rev(username) FROM users WHERE id = :ID")->bindInt('ID', 1)->fetchRow();
     $this->assertSame('testuser', $row['username']);
     $this->assertSame('6b39936f45fcf2a20d3de05c6c86c9d5', strrev(md5($row['username'])));
 }
Exemple #2
0
 public function testProfiler()
 {
     $config = new Config();
     $config->setDsn('sqlite::memory:');
     $database = new Database($config);
     $profiler = new Profiler();
     $database->addProfiler($profiler);
     $database->query("SELECT 1")->fetchAll();
     $result = $profiler->getLogData();
     $result = $result[0];
     // PHP 5.3 compatible
     $this->assertSame(1, $result->getId());
     $this->assertSame("SELECT 1", $result->getQueryString());
 }