I am trying to persist and retrieve images via PDO using USERCAKE2.0.
I am getting a invalid query error in the following method.
Exact error is:
PHP Fatal error: Call to a member function prepare() on a non-object in line 51
which translates to the method get_cert's prepare statement.
public function get_cert($certificate_number,$issue_date){
    global $mysqli,$db_table_prefix;
    $result = array();
    $stmt = $mysqli->prepare("select * from ".$db_table_prefix."certs where cert_num=? and issue_date=?");
    $stmt->bind_param('ss',$certificate_number,$issue_date);
    $stmt->execute();
    $stmt->store_result();
    $stmt->setFetchMode(PDO::FETCH_ASSOC);
    $result=$stmt->fetch();
    return $result;
}
The insert query for the same table is:
public function persist_cert(){
        global $mysqli,$db_table_prefix;
        $stmt = $mysqli->prepare('insert into '.$db_table_prefix.'certs (cert_num,certificate,access_url,issue_date) values (?,?,?,?)');
        $null = NULL;
        $stmt->bind_param('sbss',$this->cert_num,$null,$this->access_url,$this->issue_date);
        $stmt->send_long_data(2,$this->certificate);
        $this->id = $stmt->execute();
        return empty($this->id);
    }
The table structure is :
$certificate_sql = "CREATE TABLE IF NOT EXISTS `".$db_table_prefix."certs` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `cert_num` varchar(250) NOT NULL,
    `certificate` blob NOT NULL,
    `access_url` varchar(200) NOT NULL,
    `issue_date` date NOT NULL,
    PRIMARY KEY (`id`),
        UNIQUE KEY (`cert_num`,`issue_date`)
    ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
    ";
NB - $db_table_prefix and $mysqli are predefined constants in usercake 2.0.
Please let me know what is wrong in the code above. Why am I getting the error?
 
    