On Aug 16, 11:27 pm, BlueDuck <holliph...@gmail.com> wrote: > It drives me absolutely batty that all the $records have to have the > same columns or else the multiinsert fails.
Under what circumstances do rows in the same table have a different schema? > 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. The optimization is quite simply to not apply your suggested change :) > 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; > } > } In doing that you've changed e.g. an insert with 500 items into 500 individual inserts. Here's a reference http://dev.mysql.com/doc/refman/5.1/en/insert.html The "why" you want to do this might yield a different and more useful bit of info. hth, AD 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 cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en