Created
October 1, 2011 15:07
-
-
Save lloc/1256156 to your computer and use it in GitHub Desktop.
MySQL Example 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
define('MySQL_DB_HOST', 'mysql_host'); | |
define('MySQL_DB_USER', 'mysql_user'); | |
define('MySQL_DB_PASSWORD', 'mysql_password'); | |
define('MySQL_DB_NAME', 'Meine_Datenbank'); | |
class MySQL { | |
var $conn; | |
var $db; | |
var $query; | |
function MySQL () { | |
$this->conn = @mysql_connect (MySQL_DB_HOST, MySQL_DB_USER, MySQL_DB_PASSWORD); | |
if ($this->conn) { | |
$this->db = mysql_select_db (MySQL_DB_NAME); | |
} | |
} | |
function sql ($statement) { | |
if ($this->db) { | |
$this->query = mysql_query ($statement, $this->conn); | |
} | |
} | |
function result () { | |
$temp = array (); | |
if ($this->query) { | |
while ($row = mysql_fetch_array ($this->query, MYSQL_ASSOC)) { | |
$temp[] = $row; | |
} | |
mysql_free_result ($this->query); | |
} | |
return $temp; | |
} | |
function error () { | |
return mysql_error (); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Related post: http://lloc.de/mysql-und-php-trenn-das-mal.html