View Single Post
Old 12-17-2012, 02:56 AM   PM User | #30
tangoforce
Senior Coder

 
tangoforce's Avatar
 
Join Date: Feb 2011
Location: Your Monitor
Posts: 3,665
Thanks: 45
Thanked 456 Times in 444 Posts
tangoforce will become famous soon enoughtangoforce will become famous soon enough
Ok, ignore the incoherent mumblings about passing by reference... I've found a hack

This should be about right (it's late you might need to make minor adjustments but I've run tons of experiments and stuff before putting this together):
PHP Code:
class BindParam{
    private 
$values = array(), $types '';
   
    public function 
add($type$value ){
        
$this->values[] = $value;
        
$this->types .= $type;
    }
   
    public function 
get(){
        
$Result array_merge(array($this->types), $this->values);
        
        
//Hack for dealing with pass by reference crap
        
foreach($Result as $Key => &$Value)
            {
            
$Refs[$Key] = &$Value
            }
            
        return 
$Refs;
    }
}

$bindParam = new BindParam();

//First parameter is member_id from session
$bindParam->add('i'$sessMemberID);

foreach(
$_POST['msgArray'] as $msgID => $msgValue){
   
$Count += 1;
   
$bindParam->add('i'$msgID);
   
$IDs[] = "message_id=?";
}

$MessageIDs implode(' or '$IDs);

// Build query.
$q1 "UPDATE private_msg_recipient SET read_on=NULL, updated_on=NOW() WHERE member_id_to=? AND ($MessageIDs) LIMIT $Count";
//UPDATE private_msg_recipient SET read_on=NULL, updated_on=NOW() WHERE member_id_to=? AND (message_id=? or message_id=? or message_id=?) LIMIT 3  

// Prepare statement.
$stmt1 mysqli_prepare($dbc$q1);

// Bind variables to query.
call_user_func_array(array($stmt1'bind_param'), $bindParam->get()); 

// Execute query.
mysqli_stmt_execute($stmt1);

// Verify Update.
if (mysqli_stmt_affected_rows($stmt1)==1){
   
// Update Succeeded.
   
$redirectView 'incoming';

}else{
   
// Update Failed.


Good night, god bless and Merry Christmas
__________________
Please don't be rude: Put your php code in [php][/php] tags. It is a sticky topic at the top of the forum and it HELPS us to HELP YOU!
TIP: Coding styles and $end errors :::::::::: TIP: Warning: Cannot modify header information - headers already sent :::::::::: TIP: Quotes / Parse error: syntax error, unexpected T_..
PHP Code:
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value. 
Explanation: The IE if(isset($_POST['submit'])) bug explained.

Last edited by tangoforce; 12-17-2012 at 03:03 AM..
tangoforce is offline   Reply With Quote