PHP Mysqli类扩展

时间:2013-02-19 21:51:10

标签: php mysqli extends

问题已解决。 UserControl函数关闭数据库连接。感谢

当我厌倦real_escape_string()功能时,出现问题

  

致命错误:在...中的非对象上调用成员函数real_escape_string()

SqlClass:

class Sql {

    protected $mysqli = '';
    private $table = '';
    private $where = '';
    private $limit = '';
    private $orderby = '';
    private $data = '';
    private $columns = '';

    function __construct(){
        try{
            if(!$this->mysqli){
                $this->mysqli = new mysqli(VTConnectIP, VTConnectRoot, VTConnectPass, VTConnectDB)
                                                                        or die(mysqli_connect_error());
                $this->tr_fix_db();
            }
            return;
        }catch(Exception $ex){
            echo $ex->getMessage(); 
        }   
    }

扩展课程:

class LoginClass extends Sql
{
    private $username;
    private $password;
    private $email;
    private $errors = array();

    public function __construct(){
        parent::__construct();
    }

    public function username($data){
        $this->UserControl($data);
        $this->username = $this->mysqli->real_escape_string($data); // Error Code
        return $this;
    }

0 个答案:

没有答案