[Solar-talk] model branch: insert(), _applyFilters() & autoincrement

Paul M Jones pmjones at ciaweb.net
Mon Feb 19 07:45:54 PST 2007


On Feb 19, 2007, at 9:31 AM, Paul M Jones wrote:

> On Feb 17, 2007, at 10:36 AM, Rodrigo Moraes wrote:
>
>> In the model branch, it seems that there is a problem when you try to
>> insert a record with an autoincremented primary key because it will
>> not validate in _applyFilters() - there is no 'validateInt' yet for
>> the autoincremented value.

Here's something that might work; can you try it instead of the hard- 
coded value?

In Solar_Sql_Model::_applyFilters(), around line 1677, change from  
this ...

             // is the value required?
             if (empty($this->_table_cols[$key]['require'])) {
                 $filter->setRequire(false);
             } else {
                 $filter->setRequire(true);
             }

... to this:

             // is the column required?
             $filter->setRequire($this->_table_cols[$key]['require']);

             // is the column an auto-increment?
             if ($this->_table_cols[$key]['autoinc']) {
                 // not required after all, it will be inserted by the
                 // database.
                 $filter->setRequire(false);
             }

Let me know how it goes.



--

Paul M. Jones  <http://paul-m-jones.com>

Solar: Simple Object Library and Application Repository
for PHP5.  <http://solarphp.com>

Join the Solar community wiki!  <http://solarphp.org>

Savant: The simple, elegant, and powerful solution for
templates in PHP.  <http://phpsavant.com>




More information about the solar-talk mailing list