Created
June 16, 2014 10:10
-
-
Save ezimuel/eff5072ef7ccd0298a6b to your computer and use it in GitHub Desktop.
Testing ORDER BY for Zend_Db_Select of ZF1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
set_include_path('path/to/zf1/library'); | |
require_once 'Zend/Db.php'; | |
$db = Zend_Db::factory('Pdo_Mysql', array( | |
'host' => '127.0.0.1', | |
'username' => '', | |
'password' => '', | |
'dbname' => 'test' | |
)); | |
$select = $db->select(); | |
$select->from(array('p' => 'product'))->order('productId ASC'); | |
$expected = 'SELECT `p`.* FROM `product` AS `p` ORDER BY `productId` ASC'; | |
test($expected, $select); | |
$select = $db->select(); | |
$select->from(array ('p' => 'product'))->order(array ('productId ASC', 'userId DESC')); | |
$expected = 'SELECT `p`.* FROM `product` AS `p` ORDER BY `productId` ASC, `userId` DESC'; | |
test($expected, $select); | |
function test($expected, $select) { | |
if ($expected === $select->assemble()) { | |
printf ("OK: test passed\n"); | |
} else { | |
printf ("FAIL: the select is not correct, %s\n", $select->assemble()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ok, really weird… your tests pass on our environments, even though we got issues there.
What I did in preparation: