PDA

Click to See Complete Forum and Search --> : Good database class?


da_silvy
May 11th, 2003, 10:08 PM
Does anyone have a link to a good mysql database class or can point me in the right direction and make some suggestions

thanks

The Hobo
May 12th, 2003, 11:16 PM
What is a MySQL database class?

phpman
May 13th, 2003, 12:20 AM
it is a class that connects and queries and all that other stuff. I use the vbullitens free version's db class. does really well for what I need. but it shouldn't be hard to write your own or head over to www.hotscripts.com and find one there. or www.zend.com has pleny of code snippets of the sort.

The Hobo
May 13th, 2003, 11:07 AM
I still don't understand. But okay.

phpman
May 13th, 2003, 01:42 PM
that is because you are still thinking in that box, just kidding ;)

a db class that I think he is talking about is like this. you know what a class is right? well this class does all the connection stuff to the db. all you have to do in your script is connect to this class and do regular stuff.

so lets say I have a db class.


class DB_BIG {
var $Host; // Hostname of our MySQL server.
var $Database; // Logical database name on that server.
var $User; // User and Password for login.
var $Password;

var $Link_ID = 0; // Result of mysql_connect().
var $Query_ID = 0; // Result of most recent mysql_query().
var $record = array(); // current mysql_fetch_array()-result.
var $Row; // current row number.

var $errno = 0; // error state of query...
var $errdesc = "";
var $appshortname = SITE_NAME;
var $reporterror = 1;

function connect() {

$this->Host = HOSTNAME;
$this->User = USER;
$this->Password = PASS;
$this->Database = DBNAME;

if ( 0 == $this->Link_ID ) {
$this->Link_ID=@mysql_connect($this->Host, $this->User, $this->Password);
if (!$this->Link_ID) {
$this->halt("Link-ID == false, connect failed");
}
if (!mysql_query(sprintf("use %s",$this->Database),$this->Link_ID)) {
$this->halt("Cannot connect to database ".$this->Database);
}
}
}


function query($Query_String) {
// do query
$this->Query_ID = @mysql_query($Query_String,$this->Link_ID);
if (!$this->Query_ID) {
$this->halt("Invalid SQL: ".$Query_String);
}
return $this->Query_ID;
}

that is a short version of vbullitens free version.

so in my script I use it like so,

$db_addCobrand = new DB_BIG; // start a instance of the class
$db_addCobrand->connect(); // connect to the db
$db_addCobrand->query("select * from table"); // run my query

that is a db class in a nut shell.

do you get it now? all it is is a class that handles all the connections to the db.

The Hobo
May 13th, 2003, 05:05 PM
Originally posted by phpman
do you get it now? all it is is a class that handles all the connections to the db.

Ah, I see how that could be useful.

da_silvy
May 14th, 2003, 06:00 AM
hmm the vbulletin lite db class?

i was thinking of writing a forum, do either of you want in or will i attempt this voyage solo :p

phpman
May 14th, 2003, 07:49 AM
why another forum? hobo started one not sure if he is still doing it, I can't alocate the time as another project is in my bag. in my opinion there are too many out there as it is. but good luck :)

The Hobo
May 14th, 2003, 04:04 PM
I started developing my own forum, but lost interest in working on it.

da_silvy
May 15th, 2003, 05:30 AM
Originally posted by phpman
why another forum? hobo started one not sure if he is still doing it, I can't alocate the time as another project is in my bag. in my opinion there are too many out there as it is. but good luck :)

i want to make an awesome free forum that will rival vbb :p