function testSql_FromJoinOn() { $Sql_From = new A_Sql_From(); $Sql_From->table('foo')->join('bar', 'baz')->on('foo_id', 'id'); $this->assertEqual($Sql_From->render(), "foo INNER JOIN bar ON (bar.foo_id = baz.id)"); $Sql_From = new A_Sql_From(); $Sql_From->table('foo')->join(new A_Sql_Join('bar', 'baz', 'LEFT'))->on('foo_id', 'id'); $this->assertEqual($Sql_From->render(), "foo LEFT JOIN bar ON (bar.foo_id = baz.id)"); }
<?php include 'config.php'; $from = new A_Sql_From(); echo $from->table(array('table1', 'table2', 'table3'))->render(); echo "\n<br/>\n"; dump($from); $from = new A_Sql_From(); echo $from->table('table1')->join('table2')->on('column5', 'column6')->render(); echo "\n<br/>\n"; dump($from); $from = new A_Sql_From(); echo $from->table('table1')->join('table2', 'RIGHT')->on('column5', 'column6')->render(); echo "\n<br/>\n"; dump($from); $from = new A_Sql_From(); echo $from->table('table1')->join('table2', 'table1', 'LEFT')->on('column5', 'column6')->render(); echo "\n<br/>\n"; dump($from); $from = new A_Sql_From(); echo $from->table('foo0')->join('foo0', 'bar0', 'LEFT')->on('column1', 'column2')->join('bar0', 'baz0', 'OUTER')->on('column3', 'column4')->render(); echo "\n<br/>\n"; dump($from);