php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45851 mysqli_fetch_object should detect empty column names
Submitted: 2008-08-18 14:18 UTC Modified: 2008-11-17 17:34 UTC
From: peterbelm at gmail dot com Assigned: mysql (profile)
Status: Not a bug Package: MySQLi related
PHP Version: 5.2.6 OS: *
Private report: No CVE-ID: None
 [2008-08-18 14:18 UTC] peterbelm at gmail dot com
Description:
------------
If a column is select with an empty name like so:

SELECT id as ``...

You get a fatal error "Cannot access empty property". Looking through the Zend code I found it happens when looking up property info.
Shouldn't mysqli check for empty property names when creating the object, triggering it's own (more useful) error?

Reproduce code:
---------------
$link = mysqli_connect($host, $user, $pass);
mysqli_select_db($schema);
$result = mysqli_query("select 'test' as ``", $link);
$obj = mysqli_fetch_object($result);

Expected result:
----------------
A fatal error along the lines of "Empty column name in SQL"

Actual result:
--------------
Fatal error: "Cannot access empty property"

Generated from Zend/zend_object_handlers.c:188

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-08-19 00:23 UTC] johannes@php.net
Assigned to mysql
 [2008-11-17 17:34 UTC] johannes@php.net
The error message should be clear enough, changing the behavior there creates costs which aren't justified by such a tiny cosmetic improvement.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 13:01:31 2024 UTC