note 52352 deleted from ref.gmp by nlopess
| From: | nlopess@php.net | Date: | Mon, 01 May 2006 21:43:35 +0000 |
| Subject: | note 52352 deleted from ref.gmp by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-110296@lists.php.net to get a copy of this message | ||
Note Submitter: sabata dot mereeotlhe at gmail dot com
----
I did further research and figured out a solution, that i felt was sufficient for the purpose I
wanted it for which was, I needed to change a binary representation in a db to signal user overall
status within the system for multi statuses eg: check that they have received a comfirmation email
or has been banned or rejected and so on whatever you need to signal
PS: the script below is if you using ADOdb with PHP 5.0.4 not tested else where under Windows XP SP2
like in my instance
<<<<<<<<<<=============>>>>>>>>>>>>>
<?php
function change_status($users_id, $change_flag, $conn)
{
$sql = sprintf("SELECT users_status
FROM users where users_id = users_id");
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
$rs = &$conn->Execute($sql);
foreach($rs as $k => $row)
{
$record = $row[0];
}
$xor1 = base_convert($record, 2, 10);
$xor2 = base_convert($change, 2, 10);
$xor3 = ((int)$xor1 ^ (int)$xor2);
$xor4 = sprintf("%b", $xor3);
$sql = sprintf("UPDATE users
SET users_status = '$xor4'
WHERE users_id = $users_id");
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
$rs = &$conn->Execute($sql);
}
//accessing the function:
change_status(1, "1010101010101", $conn);
?>
==========================
i hope some has the same problem I had and finds this useful...
;-)