Example #1
0
 public function testGet() {
 	$settings = $this->getMock('ML\SQL\Settings');
 	$connection = $this->getMock('ML\SQL\Connection_PDO_Sqlite', array(), array($settings));
 	$strategy = $this->getMock('ML\SQL\Strategy_Sqlite', array(), array($connection));
 	$sql = new SQL($connection, $strategy);
 	$strategy->expects($this->never())->method('limit');
 	$sql->get("SELECT * FROM cat WHERE id = ?", array(1));
 	
 	$strategy = $this->getMock('ML\SQL\Strategy_Sqlite', array(), array($connection));
 	$sql = new SQL($connection, $strategy);
 	$strategy->expects($this->once())->method('limit');
 	$sql->get("SELECT * FROM cat WHERE id = ?", array(1), 10, 20);
 }
Example #2
0
File: 005.php Project: renq/ML-Lib
<pre>
<?php

use ml\sql\SQL;

date_default_timezone_set('Europe/Warsaw');

include('../ml/ml.php');
$dsn = 'pgsql://*****:*****@localhost/postgres';

error_reporting(E_ALL);
ini_set('display_errors', true);



$pdo = new \PDO("pgsql:host=localhost;port=5432;dbname=postgres", 'postgres', 'mlsni2');
$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);

$connection = new ml\sql\Connection_PDO_PostgreSQL(new ml\sql\Settings());
$connection->setHandle($pdo);
$strategy = new ml\sql\Strategy_PostgreSQL($connection);

$sql = new SQL($connection, $strategy);

print_r($sql->get("SELECT * FROM cats WHERE id = ?", array(1)));