I have written this class because I find that the MySQL commands that are provided in PHP are not obect orientated and are quite lengthy to have to retype time and time again.
- $sqlQueryString = 'SELECT *
- FROM MyTable
- WHERE ID = 200';
- // Do something with your data
- echo $data['value'];
- }
- $datas->query('SELECT *
- FROM MyTable
- WHERE ID = 200');
- while ($data = $datas->result()) {
- // Do something with your data
- echo $data['value'];
- }
Download the class mysql.inc.php
- private $connection;
- private $db;
- private $query;
-
- function __construct() {
- }
-
- function __destruct() {
- }
-
- function query($query) {
- $this->query = mysql_query($query, $this->connection) or die('<p>'.mysql_error($this->connection).'<br>'.$query.'</p>');
- }
-
- }
-
- function result() {
- }
-
- function result_array() {
- $data[] = $row;
- }
- return $data;
- }
-
- function insert_id() {
- }
- }
