0

私は次のクラスを持っています

class mydbclass extends MySQLi {

public function __construct($host, $user, $pass, $db) {

    parent::__construct($host, $user, $pass, $db);

    if (mysqli_connect_errno()) {

        $this->greh(mysqli_connect_error());
        exit();
    }
}


function mquery($sql){

    if(!($result = $this->query($sql)))
    {

        $emsg = $this->error;
        $enum = $this->errno;
        echo 'Error with msg: ' . $emsg . ' and num: ' .$enum;

    } else {
        echo 'ok';
    }
}}

同じファイル (「mdb.php」) から呼び出すと、正常に動作します。

ただし、index.php などで必要な場合は、エラー msg と num をキャッチしていません。

私はこことグーグルで多くの時間を費やしていますが、この動作を理解できません。

index.php のコードは次のとおりです。

require_once ('databasecontrol.php');
$db = new mydb('127.0.0.1', 'x', 'x', 'x');
$db->mquery($sqlt);
4

0 に答える 0