Trace: » rotating_logs » rtorrent » setting_the_time_without_tzconfig » setting_up_vps » setup_firefox_on_edgy_eft » unattended_upgrades » upgrade_ubuntu_distro » use_the_ubuntu_live_cd_to_reinstall_a_windows_master_boot_record_mbr » ubuntu_oneiric_on_the_asus_x52f » test.php
You are currently not logged in! Enter your authentication credentials below to log in. You need to have cookies enabled to log in.
<?php /* * Created on 22 Jul 2007 * Chris testing stuff */ class database { var $dbhandle; //make an instance variable 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 // what we could do here is to pass an array of info in a key->value format and then // act upon those e.g. array("tablename"=>"testtab","id"=>"int len11 autoincrement nonnull", // "firstname"=>"varchar(255)","lastname"=>"varchar(255)"); { //next we use the "this->" to reference the class variable "$dbhandle" //we could also use this to call methods within the class. //eg. if(!isset($dbhandle)){$this->create();} // this->$dbhandle = sqlite_open('sqlitetest.sqlite'); // this would then check to see if the object had correctly initiated before // attempting to use it. this->$dbhandle = sqlite_open('sqlitetest.sqlite'); $sqlCreateTable = 'CREATE TABLE testtab(id, firstname, lastname)'; sqlite_exec($dbhandle, $sqlCreateTable); } public function insertRow() { } } // now lets create an instance of the object and apply the methods $myDatabase = new database(); //create an object ($myDatabase) based on the class database $myDatabase->create(); // call the "create" method of the database class $myDatabase->insertTable(); //call the "insertTable" method of the database class //database::insertTable(); ?>