13,16 → 13,12 |
$this->drawnMiddle = false; |
$this->drawnFooter = false; |
|
$this->db = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD); |
if (!$this->db) |
{ |
$this->drawError('Failed to connect to database: ' . mysql_error()); |
} |
|
if (!mysql_select_db('Tim32')) |
{ |
$this->drawError('Failed to select database: ' . mysql_error()); |
} |
try { |
$this->db = new PDO("mysql:dbname=Tim32;host=" . MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, |
array( PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'UTF8'" )); |
} catch (PDOException $e) { |
$this->drawError("Failed to connect to database!"); |
} |
} |
|
function drawHeader() |
329,15 → 325,14 |
} |
} |
|
function query($query) |
function query($query, $args) |
{ |
$result = mysql_query($query); |
if (!$result) |
{ |
$this->drawError('Query Failed: ' . $query . "\n" . 'MySQL Error: ' . mysql_error()); |
} |
|
return $result; |
$statement = $this->db->prepare($query); |
if (!$statement->execute($args)) { |
$this->drawError("Query Failed! MySQL Error: " . $statement->errorInfo()); |
} |
|
return $statement->fetchAll(); |
} |
|
function findIDs($table, $query = '') |
344,9 → 339,8 |
{ |
$array = array(); |
|
$result = $this->query('SELECT ID FROM ' . $table . ' ' . $query); |
while ($row = mysql_fetch_array($result)) |
{ |
$results = $this->query('SELECT ID FROM ' . $table . ' ' . $query); |
foreach ($results as $row) { |
array_push($array, $row['ID']); |
} |
|
355,9 → 349,8 |
|
function getUserByID($id) |
{ |
$result = $this->query('SELECT * FROM Users WHERE ID = "' . $id . '"'); |
while ($row = mysql_fetch_array($result)) |
{ |
$results = $this->query('SELECT * FROM Users WHERE ID = "' . $id . '"'); |
foreach ($results as $row) { |
$user = new User; |
$user->ID = $row['ID']; |
$user->accessID = $row['AccessID']; |
375,9 → 368,8 |
|
function getUserByUsername($username) |
{ |
$result = $this->query('SELECT * FROM Users WHERE Username = "' . $username . '"'); |
while ($row = mysql_fetch_array($result)) |
{ |
$results = $this->query('SELECT * FROM Users WHERE Username = "' . $username . '"'); |
foreach ($results as $row) { |
return $this->getUserByID($row['ID']); |
} |
|
397,9 → 389,8 |
|
function getBlogPost($id) |
{ |
$result = $this->query('SELECT * FROM BlogPosts WHERE ID = "' . $id . '"'); |
while ($row = mysql_fetch_array($result)) |
{ |
$results = $this->query('SELECT * FROM BlogPosts WHERE ID = "' . $id . '"'); |
foreach ($results as $row) { |
$post = new BlogPost; |
$post->ID = $row['ID']; |
if ($row['ParentID'] == -1) |
426,9 → 417,8 |
|
function getProject($id) |
{ |
$result = $this->query('SELECT * FROM Projects WHERE ID = "' . $id . '"'); |
while ($row = mysql_fetch_array($result)) |
{ |
$results = $this->query('SELECT * FROM Projects WHERE ID = "' . $id . '"'); |
foreach ($results as $row) { |
$project = new Project; |
|
$project->ID = $row['ID']; |
449,9 → 439,8 |
|
function getForumCategory($id) |
{ |
$result = $this->query('SELECT * FROM ForumCategories WHERE ID = "' . $id . '"'); |
while ($row = mysql_fetch_array($result)) |
{ |
$results = $this->query('SELECT * FROM ForumCategories WHERE ID = "' . $id . '"'); |
foreach ($results as $row) { |
$f = new ForumCategory; |
|
$f->ID = $row['ID']; |
467,9 → 456,8 |
|
function getForumPost($id) |
{ |
$result = $this->query('SELECT * FROM ForumPosts WHERE ID = "' . $id . '"'); |
while ($row = mysql_fetch_array($result)) |
{ |
$results = $this->query('SELECT * FROM ForumPosts WHERE ID = "' . $id . '"'); |
foreach ($results as $row) { |
$f = new ForumPost; |
|
$f->ID = $row['ID']; |