function __construct($connection, $initSqlFile)
 {
     parent::__construct($initSqlFile);
     $this->connection = $connection;
     mysql_select_db($this->getDatabaseName(), $connection);
     $this->queries = array();
 }
 function __construct(\Nette\Database\Connection $connection, $initSqlFile, \Nette\Database\IStructure $structure = null)
 {
     parent::__construct($initSqlFile);
     $this->connection = $connection;
     if (!$structure) {
         $storage = new \Nette\Caching\Storages\MemoryStorage();
         $structure = new \Nette\Database\Structure($connection, $storage);
     }
     $this->db = new \Nette\Database\Context($connection, $structure);
     $_this = $this;
     $this->connection->onQuery[] = function ($connection, $result) use($_this) {
         $_this->logQuery($result);
     };
 }
示例#3
0
 /**
  * @param \PDO $pdo Use PDO without specified database name, i.e. "mysql:host=localhost".
  * The database will be created automatically.
  * @param string $initSqlFile
  */
 function __construct(\PDO $pdo, $initSqlFile)
 {
     parent::__construct($initSqlFile);
     $this->db = $pdo;
 }