Skip to content

Instantly share code, notes, and snippets.

@lloc
Created October 1, 2011 15:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lloc/1256156 to your computer and use it in GitHub Desktop.
Save lloc/1256156 to your computer and use it in GitHub Desktop.
MySQL Example 2
<?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 ();
}
}
?>
@lloc
Copy link
Author

lloc commented Oct 1, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment