Index: trunk/phase3/includes/db/Database.php |
— | — | @@ -1258,6 +1258,14 @@ |
1259 | 1259 | } |
1260 | 1260 | |
1261 | 1261 | /** |
| 1262 | + * @param $options array |
| 1263 | + * @return string |
| 1264 | + */ |
| 1265 | + function makeInsertOptions( $options ) { |
| 1266 | + return implode( ' ', $options ); |
| 1267 | + } |
| 1268 | + |
| 1269 | + /** |
1262 | 1270 | * INSERT wrapper, inserts an array into a table |
1263 | 1271 | * |
1264 | 1272 | * $a may be a single associative array, or an array of these with numeric keys, for |
— | — | @@ -1285,6 +1293,8 @@ |
1286 | 1294 | $options = array( $options ); |
1287 | 1295 | } |
1288 | 1296 | |
| 1297 | + $options = $this->makeInsertOptions( $options ); |
| 1298 | + |
1289 | 1299 | if ( isset( $a[0] ) && is_array( $a[0] ) ) { |
1290 | 1300 | $multi = true; |
1291 | 1301 | $keys = array_keys( $a[0] ); |
— | — | @@ -1293,7 +1303,7 @@ |
1294 | 1304 | $keys = array_keys( $a ); |
1295 | 1305 | } |
1296 | 1306 | |
1297 | | - $sql = 'INSERT ' . implode( ' ', $options ) . |
| 1307 | + $sql = 'INSERT ' . $options . |
1298 | 1308 | " INTO $table (" . implode( ',', $keys ) . ') VALUES '; |
1299 | 1309 | |
1300 | 1310 | if ( $multi ) { |
Index: trunk/phase3/includes/db/DatabaseSqlite.php |
— | — | @@ -363,23 +363,45 @@ |
364 | 364 | } |
365 | 365 | |
366 | 366 | /** |
367 | | - * Based on generic method (parent) with some prior SQLite-sepcific adjustments |
| 367 | + * @param $options array |
| 368 | + * @return string |
368 | 369 | */ |
369 | | - function insert( $table, $a, $fname = 'DatabaseSqlite::insert', $options = array() ) { |
370 | | - if ( !count( $a ) ) { |
371 | | - return true; |
372 | | - } |
373 | | - if ( !is_array( $options ) ) { |
374 | | - $options = array( $options ); |
375 | | - } |
| 370 | + function makeUpdateOptions( $options ) { |
| 371 | + $options = self::fixIgnore( $options ); |
| 372 | + return parent::makeUpdateOptions( $options ); |
| 373 | + } |
376 | 374 | |
| 375 | + /** |
| 376 | + * @param $options array |
| 377 | + * @return array |
| 378 | + */ |
| 379 | + static function fixIgnore( $options ) { |
377 | 380 | # SQLite uses OR IGNORE not just IGNORE |
378 | 381 | foreach ( $options as $k => $v ) { |
379 | 382 | if ( $v == 'IGNORE' ) { |
380 | 383 | $options[$k] = 'OR IGNORE'; |
381 | 384 | } |
382 | 385 | } |
| 386 | + return $options; |
| 387 | + } |
383 | 388 | |
| 389 | + /** |
| 390 | + * @param $options array |
| 391 | + * @return string |
| 392 | + */ |
| 393 | + function makeInsertOptions( &$options ) { |
| 394 | + $options = self::fixIgnore( $options ); |
| 395 | + return parent::makeInsertOptions( $options ); |
| 396 | + } |
| 397 | + |
| 398 | + /** |
| 399 | + * Based on generic method (parent) with some prior SQLite-sepcific adjustments |
| 400 | + */ |
| 401 | + function insert( $table, $a, $fname = 'DatabaseSqlite::insert', $options = array() ) { |
| 402 | + if ( !count( $a ) ) { |
| 403 | + return true; |
| 404 | + } |
| 405 | + |
384 | 406 | # SQLite can't handle multi-row inserts, so divide up into multiple single-row inserts |
385 | 407 | if ( isset( $a[0] ) && is_array( $a[0] ) ) { |
386 | 408 | $ret = true; |