Issues

ZF-7734: Too many columns in Pdo_Mysql query crashes Zend Studio Unit Test.

Description

If I run the following "bad" code snippet in a unit test it grinds to a halt with the following messages: "CGI / FastCGI has stopped working" (windows pop-up) and "Test case was unexpectedly terminated". I can resolve it by removing columns. The error does not occur outside Zend Studio (i.e. when I call the controller which uses this "bad" code).

I'm using the Pdo_Mysql adapter and it seems to fail at the lowest level, on various Windows based environments (Vista & XP).

--- bad code (too many columns?)---

$sql = "select * from auth_view_privileges where privilege_id = " . $filter->filter($id);
$result = $this->db->fetchRow($sql);

--- good code (less columns) ---

$sql = "select privilege_id, load_dts, status, privilege_name from auth_view_privileges where privilege_id = " . $filter->filter($id);
$result = $this->db->fetchRow($sql);

p.s. using a latest trial version, we're evaluating the framework and IDE with the goal to adopt it as primary tech. stack here.

Best Regards, Onno

Comments

This is not a ZF issue, but an issue with your RDBMS.

One way you can use ZF to protect you in such situations is to use Zend_Db_Select to create your queries. For example, try this:


$columns = array(
    'privilege_id', 
    'load_dts', 
    'status', 
    'description',
    'privilege_name', 
    'createdby', 
    'modifiedby',
);
$select = $this->db->select();
$select->from('auth_view_privileges', $columns)
       ->where('privilege_id = ?', $id);
$result = $this->db->fetchRow($select);

The above code will ensure that all input is properly escaped for you RDMBS solution, and also quote all table and column names to ensure you do not have issues with reserved keywords.

It's not the description column, it's the amount of columns that causes the crashes, was a bit too hasty in my reporting, it actually doesn't matter which column I exclude ...

I used to have: "select * from auth_view_privileges"

which initially crashed my unit tests (and still does for that matter on my work (Vista 64bit) and private machine (XP Pro)). It's driving me nuts, should prob. get a real OS :D

Any thoughts?


'php-cgi.exe': Loaded 'H:\Zend\Zend Studio - 7.0.0\plugins\org.zend.php.debug.debugger.win32.x86_5.2.26.v20090806\resources\php5\php-cgi.exe'

Hi!

I had similar issue with Zend Studio 7.2.0 Build ID: 20100421 on Windows XP. While running unittest, the PHP binary crashed when making SELECT query containing wildcard (*).

The problem seems to be the php_pdo_mysql.dll PHP extension included in Zend Studio debugger plugin.

I managed to resolve the issue by adding ZendDebugger PHP extension do my XAMPP 1.7.1 installation (http://forums.zend.com/viewtopic.php/?f=59&t=962…) and configuring Zend Studio to use XAMPP php-cgi.exe binary for debugging (Window > Preferences > PHP > PHP Executeables).

Hope this saves someone's day, Margus