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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: peterbelm at gmail dot com
New email:
PHP Version: OS:

 

 [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

Add a Patch

Pull Requests

Add a Pull Request

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: Thu Mar 28 19:01:29 2024 UTC