I'm not what is the issue with this code, i'm trying to bind value but it is not working properly. I'm getting
INSERT INTO menucategory (menu_type,menu_order,menu_status) VALUES (?,?,?)
as it is
Here is my code
<?php
class RDBConnection{
private $host,$user,$password,$dbname;
public $dbh,$sth;
function __construct(){
$this->host="localhost";
$this->user="user";
$this->password="pass";
$this->dbname="zczc";
}
// connect method create connection
function connect(){
try{
$this->dbh=new PDO("mysql:host=$this->host;dbname=$this->dbname",$this->user,$this->password);
// set the PDO error mode to exception
//$this->dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch (PDOException $e){
echo $e->getMessage();
}
}
// disconnect method disconnect connection created
function disconnect(){
$this->dbh=null;
}
// insert
function inserMenu($menu){
$this->sth=$this->dbh->prepare("INSERT INTO menucategory (menu_type,menu_order,menu_status) VALUES (?,?,?)");
$this->sth->bindParam(1, $menu[0]);
$this->sth->bindParam(2, $menu[1]);
$this->sth->bindParam(2, $menu[2]);
$this->sth->execute();
return true;
}
}
?>
I referred it from here http://php.net/manual/en/pdostatement.bindparam.php#118975