Exemple #1
0
 /**
  * Constructor.
  *
  * @param \atk4\dsql\Connection|string $connection
  * @param string                       $user
  * @param string                       $password
  * @param array                        $args
  */
 public function __construct($connection, $user = null, $password = null, $args = [])
 {
     if ($connection instanceof \atk4\dsql\Connection) {
         $this->connection = $connection;
         return;
     }
     if (is_object($connection)) {
         throw new Exception(['You can only use Persistance_SQL with Connection class from atk4\\dsql', 'connection' => $connection]);
     }
     // attempt to connect.
     $this->connection = \atk4\dsql\Connection::connect($connection, $user, $password, $args);
 }
Exemple #2
0
 public function testException2()
 {
     $this->setExpectedException('atk4\\dsql\\Exception');
     $c = Connection::connect('');
 }
Exemple #3
0
 public function testSQLite()
 {
     $c = Connection::connect($GLOBALS['DB_DSN'], $GLOBALS['DB_USER'], $GLOBALS['DB_PASSWD']);
     return (string) $c->expr("SELECT date('now')")->getOne();
 }
Exemple #4
0
 public function __construct()
 {
     $this->c = Connection::connect($GLOBALS['DB_DSN'], $GLOBALS['DB_USER'], $GLOBALS['DB_PASSWD']);
     $this->pdo = $this->c->connection();
     $this->pdo->query('CREATE TEMPORARY TABLE employee (id int not null, name text, surname text, retired bool, PRIMARY KEY (id))');
 }