Jump to content
Larry Ullman's Book Forums

Recommended Posts

I am looking to recreate the following function from PDO to MySQLi but having some problems, I've been over the PHP website to read the functions. I'm trying to modularize my code in like the MVC pattern. 

public function bind($param, $value, $type=''){
if(is_null($type)){
   switch(true){
    case is_int($value):
            //Thinking something like, for integer etc
            $type = mysqli_stmt::bind_param(i);
            $type = PDO::PARAM_INT;
            break;
    case is_bool($value):
            $type = PDO::PARAM_BOOL;
            break;
            default:
            $type = PDO::PARAM_STR;
   }
}
$this->stmt->bindvalue($param,$value,$type);
}

Is it as simple as just replacing PDO version line to :


$type = mysqli_stmt::bind(i); or just putting $type = i;


Then in my class I am trying to call the bind function:
 
$database ->bind($stmt,$ype,$variables);
$database->execute();

Any help would be much appreciated 

 

Regards

 

My Setup

Chrome

Windows XP

Wamp

SublimeText

 

Share this post


Link to post
Share on other sites

I'm happy to help but am a bit confused. It sounds like you're overthinking this. As you already have PDO and MySQLI as OOP approaches to database interactions, what's the benefit of trying to abstract either to another level?

Share this post


Link to post
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.

Loading...

×
×
  • Create New...