Hello folks. I'm new to both coding and php, although not to computing and systems administration.
I've decided to take the leap and attempt to learn some programming :eek: To that end I've been trying to teach myself php and object oriented methodologies. I'm using php5.
This is my first attempt at writing something from scratch. I'm mucking about trying to write to an SQLite database.
<?php
/*
* Created on 22 Jul 2007
* Chris testing stuff
*/
class database
{
public function create()
//This function creates a SQLite database
{new SQLitedatabase("sqlitetest.sqlite");}
public function insertTable()
//This function inserts a table. sqlite_exec requires at least 2 inputs - the
//database handle and the data to go into it. sqlite_open opens the database
{
$dbhandle = sqlite_open('sqlitetest.sqlite');
$sqlCreateTable = 'CREATE TABLE testtab(id, firstname, lastname)';
sqlite_exec($dbhandle, $sqlCreateTable);
}
public function insertRow()
{
}
}
database::insertTable();
?>
My question is this:
How can I declare $dbhandle = sqlite_open('sqlitetest.sqlite'); just once in the class, and have $dbhandle available to all of the functions in the class. I seem to be having to declare it in every function which seems to be a waste of time.
Thankyou!