Jump to content
MakeWebGames

Escaping an array, with array_map and MySQLi ?


LordDan

Recommended Posts

Hey guys,

Do any of you know a method to escape an array using MySQLi?

For normal MySQL I'm using array_map

 

public function escapeArray( $array )
{
   return array_map( "mysql_real_escape_string", $array );
}

 

However, I'm having trouble doing the same thing for MySQLi as I'm using the OO method, not procedural.

 

public function escapeArray( $array )
{
   return array_map( "$this->_mysqli->real_escape_string", $array );
}
Link to comment
Share on other sites

<?php
//Some connection/class info etc

if ( $ins = $db->prepare ('INSERT INTO `table` (`string`, `string`, `int`) VALUES (?,?,?)') ) {
    $ins->bind_param('ssi', $strA, $strB, $int);
    $ins->execute();
    //Do more if needed
    $ins->close();
} else {
   //An error has occurred.
   //$db->error;
}
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...