Database icon

Database Integration Functions

Outside the AI Lab

There are a few different ways to use this code if you don't want it to be backed by the AI Lab's database. The easiest way is to make a local copy of the aidb.inc file, and modify the default MySQL connection options:

aidb.inc

<?php
...
// Pre-configured for AI-Lab
var $host = "localhost";
var $user = "remote";
var $pass = "";
var $db = "aidb";
...
?>

In order to use the get*By*() functions, you will need to set up your database with the same tables and relations as the AI Lab's, since the functions contain pre-written SQL queries. Download aidb.sql.gz and load it into MySQL to get an empty database with the necessary table structure.

Alternately, you can include the original copy of aidb.inc, and hand-specify the database connection options. At the moment, this only allows you to make direct use of the Result object; there is no method for modifying the default values used by the get*By*() functions. Example:

<ul>
<?php
$result = new Result("select * from people where PID < 10","<li>%Firstname% %Lastname%</li>\n");
$result->openDatabase("hostname","username","password","database");
$result->query();
echo $result;
?>

</ul>