hi, im new to classes and i was reading some information on them and I would like to know if this would work?
if it wont work could you help me fix it and explain how the class works...
classes are so confusing....
PHP:
<?php
//Database Variables
$dbhost = "localhost";
$dbuser = "test";
$dbpass = "test";
$dbname = "test";
$id = $_GET['id'];
//Database Connection Function
function dbopen() {
mysql_connect("$dbhost","$dbuser","$dbpass");
}
//Database Selection Function
function dbselect() {
mysql_select_db("$db");
}
//Database Close And Flush Function
function dbclose() {
mysql_close();
}
//Begin Mysql Classes For Getting Data
/*** NOTES ***/
/*
To call a template use $get->$template;
To call Content from database use $db->$content;
To display the template use $db->$template;
To Display the content use $db->$select;
*/
/*** End Notes ***/
class db {
var $insert;
var $update;
var $select;
var $delete;
var $fetch;
var $template;
function db($insert=\"mysql_query("insert .$content. into .$tbl");\", $update = "mysql_query("update .$content. with .$ucontent. where .$condition.");\", $select = "mysql_query("select .$id. from .$tbl.");\", $delete = "mysql_query("delete .$content. from .$tbl. where .$condition.");\", $fetch = "mysql_fetch_array($select);", $template = "mysql_query("select .$tmp. from templates");\""); {
$this->insert=$insert;
$this->update=$update;
$this->select=$select;
$this->delete=$delete;
$this->fetch=$fetch;
$this->template=$template;
}
}
//End Mysql Classes For Getting Data
//template functions
function replace() {
$content = "{content}";
$content = ereg_replace('{content}', $db->$select, $content);
print $content;
}
?>
if it wont work could you help me fix it and explain how the class works...
classes are so confusing....