Php 致命错误:调用未定义的方法mysqli_stmt::bindvalue()

Php 致命错误:调用未定义的方法mysqli_stmt::bindvalue(),php,mysql,Php,Mysql,我需要以下代码的帮助。 我得到这个错误: 致命错误:在中调用未定义的方法mysqli\u stmt::bindvalue() 第28行的C:\xampp\htdocs\MyMind2\function.php 当我运行它时 <?php class Main{ //fetching posts from database public function posts(){ global $conn; $query = $conn->pre

我需要以下代码的帮助。 我得到这个错误:

致命错误:在中调用未定义的方法mysqli\u stmt::bindvalue() 第28行的C:\xampp\htdocs\MyMind2\function.php

当我运行它时

<?php
class  Main{
    //fetching posts from database
    public function posts(){
        global $conn;
        $query = $conn->prepare("SELECT * FROM `posts`,`users` WHERE userId = user_id_p ORDER BY `post_id` DESC");
        $query->execute();
        return $query->fetchAll();
    }
    //add new post if user post 
    public function add_post($user_id,$status,$file_parh){
        global $conn; 
        if(empty($file_parh)){
            $file_parh = 'NULL';
        }
        $query = $conn->prepare('INSERT INTO `posts` (`post_id`, `user_id_p`, `status`, `status_image`, `status_time`) VALUES (NULL, ?, ?,?,  CURRENT_TIMESTAMP)');
        $query->bindValue(1,$user_id);
        $query->bindValue(2,$status);
        $query->bindValue(3,$file_parh);
        $query->execute();
        header('Location: home.php?id='.$_POST['email']);
    }
    //fetch user data by user id 
    public function user_data($user_id){
        global $conn;
        $query = $conn->prepare('SELECT * FROM users WHERE userId = ?');

        //Line 28 below

        $query->bindvalue(1,$user_id);
        $query->execute();

        return $query->fetch();
    }
}
?>


尝试查看-手动-可能重复的作为常规样式-不要使用
全局
,在这种情况下,查看依赖项注入并将连接传递到构造函数中,或者如果愿意,传递到每个方法中。这些函数中的代码似乎是为PDO编写的,它在PDO语句上有
bindValue
fetchAll
方法,但是连接是使用mysqli建立的,而mysqli没有。