01-19-2008, 11:16 PM
|
#1 (permalink)
|
|
The Acquainted
Join Date: Sep 2007
Posts: 126
Thanks: 4
|
Please review my MySQL Class.
Hello!
My PHP isn't fantastic and usually I get others to program the main classes for me. However I decided to try and make a class myself in PHP5 - some help was given over at a different community because I forgot to define some variables.
Anyway, my class:
Code:
<?php
/*
@author Sam Granger
@copyright 2008 Intrellia. All Rights Reserved.
*/
class DBConnection {
var $connection;
var $query;
public function __construct($db_server, $db_username, $db_password, $db_database) {
$this->connection = mysql_pconnect($db_server, $db_username, $db_password);
mysql_select_db($db_database, $this->connection);
}
function __destruct() {
@mysql_close($this->connection);
}
public function DBQuery($sql) {
$this->query = mysql_query($sql) or die(mysql_error());
return $this->query;
}
public function DBRow() {
$row = mysql_fetch_row($this->query);
return $row;
}
public function DBArray() {
$array = mysql_fetch_array($this->query);
return $array;
}
public function DBCount() {
$num = mysql_num_rows($this->query);
return $num;
}
}
?>
Please critisize. What could I do better?
|
|
|
|