You've already forked postfixadmin
mirror of
https://github.com/postfixadmin/postfixadmin.git
synced 2025-08-06 06:42:37 +03:00
changed db_update parameters for the most common usecase "WHERE col=value" -
column and value are separate parameters now functions.inc.php: - changed function db_update() parameters - column name and value for the WHERE condition are now two separate parameters. This means we don't need to escape_string(), add quotes etc. for most UPDATE queries. Example call: db_update('alias', 'address', $this->username, $values_array) - the previous db_update() is now called db_update_q() model/UserHandler.php: - changed db_update call to the new parameters - removed now unused variables - renamed $username to $E_username - call pacrypt directly when setting the $set array, no need for $new_db_password model/AliasHandler.php - changed db_update call to the new parameters edit-mailbox.php - switched to db_update_q() git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@931 a1433add-5e2c-0410-b055-b7f2511e0802
This commit is contained in:
@@ -1728,15 +1728,30 @@ function db_insert ($table, $values, $timestamp = array('created', 'modified') )
|
||||
/**
|
||||
* db_update
|
||||
* Action: Updates a specified table
|
||||
* Call: db_update (string table, string where, array values [, array timestamp])
|
||||
* Call: db_update (string table, string where_col, string where_value, array values [, array timestamp])
|
||||
* @param String - table name
|
||||
* @param String - WHERE condition
|
||||
* @param String - column of WHERE condition
|
||||
* @param String - value of WHERE condition
|
||||
* @param array - key/value map of data to insert into the table.
|
||||
* @param array (optional) - array of fields to set to now() - default: array('modified')
|
||||
* @return int - number of updated rows
|
||||
*/
|
||||
function db_update ($table, $where, $values, $timestamp = array('modified') )
|
||||
{
|
||||
function db_update ($table, $where_col, $where_value, $values, $timestamp = array('modified') ) {
|
||||
$where = $where_col . " = '" . escape_string($where_value) . "'";
|
||||
return db_update_q ($table, $where, $values, $timestamp = array('modified') );
|
||||
}
|
||||
|
||||
/**
|
||||
* db_update_q
|
||||
* Action: Updates a specified table
|
||||
* Call: db_update_q (string table, string where, array values [, array timestamp])
|
||||
* @param String - table name
|
||||
* @param String - WHERE condition (as SQL)
|
||||
* @param array - key/value map of data to insert into the table.
|
||||
* @param array (optional) - array of fields to set to now() - default: array('modified')
|
||||
* @return int - number of updated rows
|
||||
*/
|
||||
function db_update_q ($table, $where, $values, $timestamp = array('modified') ) {
|
||||
$table = table_by_key ($table);
|
||||
|
||||
foreach(array_keys($values) as $key) {
|
||||
|
Reference in New Issue
Block a user