Issue Type: Bug Created: 2008-01-17T23:22:21.000+0000 Last Updated: 2008-02-17T16:17:26.000+0000 Status: Resolved Fix version(s): Reporter: Hector Virgen (djvirgen) Assignee: Simon Mundy (peptolab) Tags: - Zend_Db_Table
Related issues: - ZF-1870
When news rows are created with createRow(), all of the row's fields are set to null. This causes problems when attempting to save the row to the database using save() if the table does not allow null fields. An exception is thrown when using the MySQLi adapter.
If possible, createRow() should set all of its fields to the field's default value according to the meta data in order to be consistent with the database's normal operation of the simple insert query.
Alternatively, createRow() could return a row with no fields at all (or set to an internal "not set" value), thus allowing save() to determine which fields have been set before using save(), and only use those fields when constructing the INSERT statement. The resulting SQL would then be the simplest insert possible, and allow SQL to handle missing fields appropriately.
<pre class="highlight"> INSERT INTO `table` SET `id` = NULL
The PHP code to reproduce the same insert should be:
<pre class="highlight"> $row = $table->createRow(); $row->save();
The current alternative for saving new rows to a table is to use insert(), which works properly when fields are omitted.
Posted by Simon Mundy (peptolab) on 2008-02-16T21:03:04.000+0000
We already have a way of tracking 'clean'/'dirty' data so this won't be hard to achieve. Will book it in ASAP.
Posted by Simon Mundy (peptolab) on 2008-02-17T16:17:03.000+0000
Resolved in trunk r8110
Have you found an issue?
See the Overview section for more details.