I'm using a class I found for mysql functions and such. The way they implement it, you have to connect each time you want to use a function in the class. I want a way to make it so I won't have to call a connection each time I create an SQL statement. The example they use is:
require_once('./mysql.php');
$db = new MySQL;
$db->connect(
localhost,
test_user,
test_pass,
test_db
);
$result = $db->query("SELECT * FROM test_table");
echo $db->num_rows($result);
I want to put $db->connect(localhost,user,pass,db); Into a file such as config.php and use something like:
$this->connect($host, $user, $pass, $db);
This way I only have to include one file such as config.php whenever I want to call an sql statement. How would I do this? If I try just using $this->connect in a config.php file I get an error:
[B]Fatal error:[/B] Using $this when not in object context in I:\Apache\htdocs\test.php on line 5