However just to prove it isn't MySql, I ran the following bare bones mysql query: $db = mysql_connect('localhost','MyDb','MyDb') I had a spare minute so I checked to see if anything different happened by changing the adapter to Mysqli. What's version of PHP you're using, as this may be the culprit instead. Actual - integer 0 (query got messed up somewhere.!) Expected - integer 3 (2 originals plus newly inserted value) $Adapter->insert(array('true_or_false' => 'true')) Expected - integer 1 (number of rows affected) What you're describing - correct me if wrong - is something like the following: $Adapter = Zend_Db::factory('Pdo_Mysql', array('host' => 'localhost', 'user' => 'root', 'dbname' => 'test') ) ENGINE=InnoDB DEFAULT CHARSET=utf8-bin 'true_or_false' ENUM('true','false) DEFAULT 'false', Our solution has just been to cast the number to a string value, ie : We haven't had the issue you're describing with string values and ENUM fields at all, Ashley, only those fields that contain a numeric ENUM value. Can't debug PDO in Zend Studio, so can get no further :-( It is when the pdo layer is called to do the update that the value disappears. It properly puts quotes around an enum value. Posted by Ashley Kitson (akzincdig) on T09:21:23.000+0000Ī little further delving seems to reveal that the Zend layer is doing everything you would expect. I use string values e.g.ĬREATE TABLE IF NOT EXISTS syst_test ( pid int(11) NOT NULL auto_increment, uVal int(11) NOT NULL, strVal varchar(30) default NULL, dateVal date default NULL, textVal text, floatVal float default NULL, enumVal enum('one','two') default NULL, rowSts enum('active','suspended','defunct') NOT NULL default 'active' COMMENT 'Row Status', rowUid int(11) NOT NULL default '0' COMMENT 'Last Edited By', rowDt timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP COMMENT 'Edit Datetime', PRIMARY KEY ( pid), UNIQUE KEY uVal ( uVal) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=10 I tend not to use numeric values for enums so don't experience that particular issue. Posted by Ashley Kitson (akzincdig) on T09:14:56.000+0000ĭavid said "Does this only affect ENUM's that contain numeric values for you" Now update the record, this time passing a value for the enum field. It will default to whatever you set it on the database. Insert a record to the table, without setting a value for the enum field. Create a table with a enum value that defaults to one of its allowed values. Actually a blank value is written to the database for an enumerated value. Posted by Ashley Kitson (akzincdig) on T09:10:28.000+0000Īdditional note. I have a patch to extract and submit, if it will be reviewed. Try setting a too-long value to a VARCHAR field to see what I'm talking about.ĭoes this only affect ENUM's that contain numeric values for you? I don't notice the same behavior with TINYINT. MySQL silently ignores values for fields that it doesn't understand or don't match its field definitions. You're right to include your comment on this issue, then. Same holds true for db->insert(), no enumerated types are written to the databaseĭatabase = MySql Driver/Adapter = Pdo_Mysql (the data values have been previously passed through db->quote() ) In a call to db->update($table,$data,$where) any enumerated values are not written to the database even though the $data array contains values for the enumerated type fields. Zend_Db doesn't appear to properly handle enumerated types at all! Casting the value of the field to string within PHP is a useful workaround for this issue, as Zend_Db_Adapter_Abstract no longer treats it as a numeric value. For example, a field in SQL with type "ENUM('1','0','-1')" should always quote values, particularly numeric values, before assembling a query, but this never occurs for numeric values, resulting with inaccurate queries. The logic for quoting fields in Zend_Db_Adapter_Abstract::quote() is insufficient to address fields of type ENUM that employ numeric values, even when the explicit data type is passed as the second argument. Reporter: David Rogers (al_the_x) Assignee: Ralph Schindler (ralph) Tags: - Zend_Db ZF-3448: Zend_Db_Adapter_Abstract::quote() does not properly handle ENUM values.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |