fetch_array/objectの結果を返すMVCのクラス
class DbDriver{ private $connection; private $query; private $result; public function connect() { $host = 'localhost'; $user = ''; $password = ''; $database = ''; $this->connection = mysql_connect($host, $user, $password); $this->connection = mysql_select_db($database); return TRUE; } public function disconnect() { $this->connection->mysql_close(); return TRUE; } public function prepare($query) { $this->query = $query; return TRUE; } public function query() { if (isset($this->query)) { $this->result = $this->connection->mysql_query($this->query); return TRUE; } return FALSE; } public function fetch($type = 'object') { if (isset($this->result)) { switch ($type) { case 'array': $row = $this->result->mysql_fetch_array(); break; case 'object': default: $row = $this->result->mysql_fetch_object(); break; } return $row; } return FALSE; } }
戻り値
[2012年5月30日水曜日11:55:42][エラー][クライアント]PHP致命的なエラー:30行目の/var/www/httpdocs/test/mysql.phpの非オブジェクトでメンバー関数mysql_query()を呼び出す
30行目
$this->result = $this->connection->mysql_query($this->query);
病気になります。>。<