<?php

include 'config.php';
$select = new A_Sql_Select();
$select->columns('foobar as bleh, foo.bar')->from(array('foobar', 'foo'))->where(array('id >=' => 1, 'foo NOT IN' => array(1, 2, 3, 4, 5, 6)))->orWhere(array('foo > ' => 'bar', 'OR', 'foo' => 'cheetah', 'bar' => 'wildebeast'))->where('1=1');
echo "<br>" . $select->render() . '<br/>';
$select = new A_Sql_Select();
$select->columns('foo, baz')->from(array('foobar'))->where(array("foo" => "bar"))->where(array("baz" => "qux"));
echo "<br>" . $select->render() . '<br/>';
$select = new A_Sql_Select();
$select->columns('foo, baz')->from(array('foobar'))->where(array("foo" => "'bar'"))->where(array("baz" => "qux"));
echo "<br>" . $select->render() . '<br/>';
$select = new A_Sql_Select();
$select->columns('foo, baz')->from(array('foobar'))->where(array("foo" => "'bar'", "time=NOW()", "foo>" => 42))->where(array("baz" => " AND 0) UNION SELECT ALL username, password FROM login /*"));
echo "<br>" . $select->render() . '<br/>';
$select = new A_Sql_Select();
$select->columns('foo, bar, baz')->from('foobar')->where(array('id >=' => 1))->orderBy(array('foo', 'bar'))->groupBy('baz');
echo "<br>" . $select->render() . '<br/>';
$select = new A_Sql_Select();
$select->columns('foo, bar, baz')->from('foobar')->where(array('id >=' => 1))->limit(5, 10);
//Select 5 rows with an offset of 10
echo "<br>" . $select->render() . '<br/>';
Beispiel #2
0
<?php

include 'config.php';
$select = new A_Sql_Select();
echo $select->columns()->from('tablefoo')->join('foo0', 'bar0', 'LEFT')->leftjoin('foo', 'bar')->on('foo1.column1', 'column2')->on('OR', 'column3', 'column4')->innerjoin('foo2', 'bar2')->on('column5', 'column6')->innerjoin('foo3', 'bar3')->on(array('column7' => 'column8', 'column9' => 'column10'))->where('foo', 'bar');
echo "\n<br/>\n";
$select = new A_Sql_Select();
echo $select->columns()->from('tablefoo')->join('foo0', 'bar0', 'LEFT')->on('column5', "column6")->where('foo', 'bar');
echo "\n<br/>\n";
$select = new A_Sql_Select();
echo $select->columns()->from('tablefoo')->join('foo0', 'bar0', 'LEFT')->on('column5', "'some value'")->where('foo', 'bar');
echo "\n<br/>\n";
Beispiel #3
0
 function testSql_SelectJoins()
 {
     $Sql_Select = new A_Sql_Select();
     $this->assertEqual($Sql_Select->columns('foo', 'bar')->from('foobar')->join('barfoo', 'foobar', 'LEFT')->on('foobar_id', 'id')->render(), "SELECT foo, bar FROM foobar LEFT JOIN barfoo ON (barfoo.foobar_id = foobar.id)");
 }