i have an an array
$array_to_pass; //this array is created dynamically looks like this
Array
(
[cal] => 1
[sms] => 1
[contacts] => 0
[browsing] => 1
[history] => 0
[photo] => 0
)
now i want to update table with name "my_table".in my_table there are column with name "flags" and "value_of_flags "under column 'flags' there are many flags but i want to UPDATE Only these.i mean cal,sms,contacts,browsing,history,photo
in the above array lets say [cal] => 1
so 'cal' is the name of the flag and i want to set value of 1 or 0 to 'value_of_flags' column,
the WHERE CLAUSE ll be "where id = $var"
how would i write this query ???
my table looks like this
flags value_of_flags id
a 1 555
b 0 456
call 0 236
sms 1 122
e 1 456
contacts 0 777
g 0 555
browsing 0 888
i 1 112
photo . .
. . .
. . .
EDITED
function Save_User_Prefrences($array_to_pass,$phone_service_id){
$DB = Zend_Db_Table_Abstract::getDefaultAdapter();
//$whereStr = "phone_service_id = " . (int)$phone_service_id;
foreach ($array_to_pass as $key => $value) {
$DB->update('user_preferences',
array(
$key => $value
),
"phone_service_id = " . $phone_service_id
); }
error
<b>Fatal error</b>: Uncaught exception 'PDOException' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'call' in 'field list in pdo.php
$idWhereStr = "phone_service_id = " . (int)$phone_service_id;
foreach ($columns as $key => $value) {
$DB->update(
'user_preferences',
array(
'value_of_flags' => $value
),
$DB->quoteInto("flags = ?", $key) . " AND " . $idWhereStr
);
}