命名空间内的 Mysqli

Mysqli inside namespace

我需要在命名空间内使用 mysqli 和准备好的语句,这在我尝试绑定参数之前一直工作正常,它连接查找和准备工作但在那里我收到一条错误消息说调用未定义方法。

我已经 google 完成了这个,我能从 google 中找到的就是做

use Mysql;

但这似乎没有帮助。堆栈溢出是我最后的手段。

这是整个页面:

<?php

namespace KrowdUp\Core; 

use Mysql;

class DatabaseConnect
{

private $user;
private $password;
private $database;
private $server;

//Variable for database connect
public $db;
//Variable for sql
public $dbSQL;
//Variable for db transaction
public $getData;
//Variable for db error
public $dbERROR;



public function __construct()
{

    $this->user = "user";
    $this->password = "password";
    $this->database = "databse";
    $this->server = "server";

    $this->db = new \mysqli($this->server, $this->user, $this->password, $this->database);

    if($this->db->connect_errno > 0){
        die('Unable to connect to database [' . $db->connect_error . ']');
        //Handle error
    }

}

//Set the SQL
public function setSQL($sql) 
{

    $this->dbSQL = $sql;

}



//Check the SQL
public function checkSQL()
{

    if ($this->getData = $this->db->prepare($this->dbSQL)) {

        $this->dbERROR = 1;
        return 1;
        //Handle error properly

    } else {

        $this->dbERROR = 0;
        return 0;
        //Handle error properly

    }

}   

//Bind paramaters
public function bindParam($param) 
{

    $this->db->bind_param('i',$param);

}

}

这是因为我在做一些愚蠢的事情而没有注意到还是我错过了什么?预先感谢您的帮助。

bind_param是mysqli_statement的函数,不是mysqli连接

尝试

$this->getData->bind_param('i', $param);

http://php.net/manual/en/mysqli-stmt.bind-param.php