Changeset 2333 for trunk/admin/include/functions.php
- Timestamp:
- May 6, 2008, 3:04:58 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/include/functions.php
r2325 r2333 278 278 $where_cats = '%s IN('.wordwrap(implode(', ', $ids), 120, "\n").')'; 279 279 } 280 280 281 281 // find all categories where the setted representative is not possible : 282 282 // the picture does not exist … … 395 395 { 396 396 $query = ' 397 398 399 397 INSERT INTO '.$table_name.' 398 ('.implode(',', $dbfields).') 399 VALUES'; 400 400 $first = false; 401 401 } … … 403 403 { 404 404 $query .= ' 405 405 , '; 406 406 } 407 407 … … 453 453 { 454 454 $query = ' 455 456 455 UPDATE '.$tablename.' 456 SET '; 457 457 $is_first = true; 458 458 foreach ($dbfields['update'] as $key) … … 474 474 } 475 475 $query.= ' 476 476 WHERE '; 477 477 478 478 $is_first = true; … … 483 483 $query.= ' AND '; 484 484 } 485 $query.= $key.' = \''.$data[$key].'\''; 485 if ( isset($data[$key]) ) 486 { 487 $query.= $key.' = \''.$data[$key].'\''; 488 } 489 else 490 { 491 $query.= $key.' IS NULL'; 492 } 486 493 $is_first = false; 487 494 } 488 495 $query.= ' 489 496 ;'; 490 497 pwg_query($query); 491 498 } … … 495 502 // creation of the temporary table 496 503 $query = ' 497 504 SHOW FULL COLUMNS FROM '.$tablename.' 498 505 ;'; 499 506 $result = pwg_query($query); … … 506 513 $column = $row['Field']; 507 514 $column.= ' '.$row['Type']; 508 if (!isset($row['Null']) or $row['Null'] == '') 515 516 $nullable = true; 517 if (!isset($row['Null']) or $row['Null'] == '' or $row['Null']=='NO') 509 518 { 510 519 $column.= ' NOT NULL'; 520 $nullable = false; 511 521 } 512 522 if (isset($row['Default'])) 513 523 { 514 524 $column.= " default '".$row['Default']."'"; 525 } 526 elseif ($nullable) 527 { 528 $column.= " default NULL"; 515 529 } 516 530 if (isset($row['Collation']) and $row['Collation'] != 'NULL') … … 528 542 ( 529 543 '.implode(",\n", $columns).', 530 PRIMARY KEY('.implode(',', $dbfields['primary']).')544 UNIQUE KEY the_key ('.implode(',', $dbfields['primary']).') 531 545 ) 532 546 ;'; 547 533 548 pwg_query($query); 534 549 mass_inserts($temporary_tablename, $all_fields, $datas); 535 550 // update of images table by joining with temporary table 536 551 $query = ' 537 538 552 UPDATE '.$tablename.' AS t1, '.$temporary_tablename.' AS t2 553 SET '. 539 554 implode( 540 555 "\n , ", … … 544 559 ) 545 560 ).' 546 561 WHERE '. 547 562 implode( 548 563 "\n AND ", … … 555 570 pwg_query($query); 556 571 $query = ' 557 572 DROP TABLE '.$temporary_tablename.' 558 573 ;'; 559 574 pwg_query($query);
Note: See TracChangeset
for help on using the changeset viewer.