[TYPO3-dev] exec_INSERTmultipleRows doesn't insert records, that exec_INSERTquery does

Victor Livakovsky v-tyok at mail.ru
Wed Jun 29 17:46:20 CEST 2011


Hi, list.

I'm facing weird problem and almost cut my hair with it.

I'm developing a code, that runs by Scheduler ext. Everything is cool until 
the moment, when I need to make multiple INSERT statement.
Doing It this way:
if(!empty($announces)) {
  $GLOBALS['TYPO3_DB']->exec_INSERTmultipleRows('tx_lvestate_announcements', 
array_keys($announces[0]), $announces);
  //$error = $GLOBALS['TYPO3_DB']->sql_error();
  //t3lib_div::debug($error);
}

And nothing is inserted into db (tablename is correct, 2nd argument is array 
of fieldnames, 3rd is array of arrays with correct mapping of 
fieldname=>value).
If I uncomment error lines, I get this sql error:  Column count doesn't 
match value count at line 6

I had no time to research more, so I made the code this way:
if(!empty($announces)) {
  foreach($announces as $announce) {
      $GLOBALS['TYPO3_DB']->exec_INSERTquery('tx_lvestate_announcements', 
$announce);
  }
}
And this time everything is correctly inserted. But I don't like it, since 
it stresses db more.
Anyone else experienced such a problem?

Thank you in advance. 





More information about the TYPO3-dev mailing list