Does anyone have a link to a good mysql database class or can point me in the right direction and make some suggestions
thanks
Printable View
Does anyone have a link to a good mysql database class or can point me in the right direction and make some suggestions
thanks
What is a MySQL database class?
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.
I still don't understand. But okay.
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.
that is a short version of vbullitens free version.PHP Code: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;
}
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.
Ah, I see how that could be useful.Quote:
Originally posted by phpman
do you get it now? all it is is a class that handles all the connections to the db.
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
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 started developing my own forum, but lost interest in working on it.
i want to make an awesome free forum that will rival vbb :pQuote:
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 :)