It drives me absolutely batty that all the $records have to have the
same columns or else the multiinsert fails.  Not sure if this is
really the most optimal code here, but this change in /var/www/
wednesdays/cake/tests/lib/cake_test_fixture.php in the insert function
did the trick.  I'd suggest that someone do a little optimization and
consider for the next release.  Also - no need to publish this post if
there you can route to the right place.

Essentially, I move the multiinsert into the loop so that the field
list for each record is used instead of the field list from just the
last record.

    function insert(&$db) {
        if (!isset($this->_insert)) {
            $values = array();

            if (isset($this->records) && !empty($this->records)) {
                foreach ($this->records as $record) {
                    $fields = array_keys($record);
                    $values[0] = '(' . implode(', ', array_map(array(&
$db, 'value'), array_values($record))) . ')';
                    $result = $db->insertMulti($this->table, $fields,
$values);
                    if ($result === false) return false;
                }
            }
            return true;
        }
    }

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to