PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Database » DB_DataObject » Bug #8094

Reserved words need to be escaped when used as column names

Details

Request #8094Reserved words need to be escaped when used as column names
Submitted2006-06-30 20:59 UTC
Frommartins at bebr dot ufl dot edu
StatusBogus
PackageDB_DataObject
PHP Version5.1.4
OSGentoo Linux
Roadmaps(Not assigned)

Comments

[2006-06-30 20:59 UTC] martins at bebr dot ufl dot edu

Description:
------------
When you use a back-ticked reserved word as a column name, DataObject doesn't backtick the name when it generates SQL. Thus, in a table someone here had made, they had included a column named 'when.' Unfortunently, this broke the data object, because it didn't produce backticks in its SQL. I'm using MySQL 5 if that helps.

There appear to be bugs filed against DB for not escaping column names, however I don't know exactly where the columns are escaped, and figured DataObject could patch it until DB gets around to fixing it.

Test script:
---------------
create table a (`when` date NOT NULL default '0000-00-00');
; run the class file generator
; now try to submit a date value via php

Expected result:
----------------
INSERT INTO a ( `when` ) VALUES ( '2000-01-01')

Actual result:
--------------
INSERT INTO a ( when ) VALUES ( '2000-01-01')

[2006-07-01 11:52 UTC] martins at bebr dot ufl dot edu

I think that this setting should probably be enabled by default, as the default behavior won't work with all configurations.