コード例 #1
0
ファイル: DatabaseTest.php プロジェクト: sindriphp/database
 public function testExoticDateTime()
 {
     $config = new Config();
     $config->setDateTimeFormat('W-Y');
     $sqliteDb = $this->getSQLite($config);
     $dateTime = new DateTime();
     $assertString = $dateTime->format('W-Y');
     $sqliteDb->query("INSERT INTO datetimespecial VALUES (:DATE)")->bindDate('DATE', $dateTime)->execute();
     $row = $sqliteDb->query("SELECT * FROM datetimespecial")->fetchRow();
     $this->assertSame($assertString, $row['update']);
 }
コード例 #2
0
ファイル: Database.php プロジェクト: sindriphp/database
 /**
  * @param Config $config
  */
 public function __construct(Config $config)
 {
     $this->actionQueue = new ActionQueue();
     $this->dateTimeFormat = $config->getDateTimeFormat();
     $username = $config->getUsername();
     $password = $config->getPassword();
     $dsn = $config->getDsn();
     $options = $config->getPdoOptions();
     $this->connection = new Connection($username, $password, $dsn, $options, $this->actionQueue);
 }
コード例 #3
0
ファイル: BaseQueryTest.php プロジェクト: sindriphp/database
 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());
 }