Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Testing ORDER BY for Zend_Db_Select of ZF1
<?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());
}
}
@DragonBe
Copy link

DragonBe commented Jun 16, 2014

Ok, really weird… your tests pass on our environments, even though we got issues there.

$ php gistfile1.php
OK: test passed
OK: test passed

What I did in preparation:

$ php -v
PHP 5.5.11 (cli) (built: Apr 16 2014 08:51:58)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
    with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies

$ mkdir /tmp/zf-378
$ cd /tmp/zf-378
$ svn log -l 5 https://github.com/zendframework/zf1/tags/release-1.12.7/library/Zend
------------------------------------------------------------------------
r6565 | matthew.weier.o.phinney | 2014-06-12 18:20:25 +0200 (Thu, 12 Jun 2014) | 4 lines

Merge branch 'releases/1.12.7'

1.12.7 readiness

------------------------------------------------------------------------
$ svn co https://github.com/zendframework/zf1/tags/release-1.12.7/library/Zend
$ curl -O https://gist.githubusercontent.com/ezimuel/eff5072ef7ccd0298a6b/raw/0011595bd54174c12deb46e886c47a942df8d3b9/gistfile1.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment