| 1 |
<?php |
<?php |
| 2 |
|
|
| 3 |
// $Id$ |
// $Id: pressflow_transaction.module,v 1.2.2.3 2008/04/23 19:55:55 straussd Exp $ |
| 4 |
|
|
| 5 |
class pressflow_transaction { |
class pressflow_transaction { |
| 6 |
private static $layers = 0; |
private static $layers = 0; |
| 84 |
|
|
| 85 |
// Update |
// Update |
| 86 |
if ($primary_key_set) { |
if ($primary_key_set) { |
| 87 |
$sql = 'UPDATE {' . db_escape_table($table) . '} SET '; |
$sql = 'UPDATE {' . db_escape_table($table) . '} t SET '; |
| 88 |
$updates = array(); |
$updates = array(); |
| 89 |
foreach ($fields as $key => $value) { |
foreach ($fields as $key => $value) { |
| 90 |
if (!in_array($key, $primary_key)) { |
if (!in_array($key, $primary_key)) { |
| 91 |
if ($value !== NULL) { |
if ($value !== NULL) { |
| 92 |
$updates[] = $key . ' = "' . db_escape_string($value) . '"'; |
$updates[] = 't.' . $key . ' = "' . db_escape_string($value) . '"'; |
| 93 |
} |
} |
| 94 |
else { |
else { |
| 95 |
$updates[] = $key . ' = NULL'; |
$updates[] = 't.' . $key . ' = NULL'; |
| 96 |
} |
} |
| 97 |
} |
} |
| 98 |
} |
} |
| 157 |
$values[] = 'NULL'; |
$values[] = 'NULL'; |
| 158 |
} |
} |
| 159 |
} |
} |
| 160 |
$sql .= '(`' . implode('`,`', $keys) . '`) '; |
$sql .= '({' . db_escape_table($table) . '}.' . implode(',{' . db_escape_table($table) . '}.', $keys) . ') '; |
| 161 |
$sql .= 'VALUES (' . implode(',', $values) . ')'; |
$sql .= 'VALUES (' . implode(',', $values) . ')'; |
| 162 |
db_query($sql); |
db_query($sql); |
| 163 |
|
|
| 164 |
// If we were passed a simple primary key, return the same |
// If we were passed a scalar primary key, return the primary key of the new row as a scalar |
| 165 |
if ($return_simple_primary_key) { |
if ($return_simple_primary_key) { |
| 166 |
return $fields[$primary_key[0]]; |
return $fields[$primary_key[0]]; |
| 167 |
} |
} |