Prior to running this example you must first download and install the
world test database from MySQL's website.
Then, you must edit this file (example.php) and change the settings of host, user name, password
and database to match your configuration.
debug = true;
// connect to the MySQL server and select the database
$db->connect(
'', // host
'', // user name
'', // password
'' // database
);
$db->set_charset();
// let's work with a country
$country = 'Romania';
// get the country's code
$country_code = $db->dlookup('Code', 'country', 'Name = ?', array($country));
// get all the cities for the country code
$db->query('
SELECT
Name
FROM
city
WHERE
CountryCode = ?
ORDER BY
Name
', array($country_code));
// get all the languages spoken for the country code
$db->query('
SELECT
Language,
IsOfficial,
Percentage
FROM
countrylanguage
WHERE
CountryCode = ?
ORDER BY
Percentage DESC
', array($country_code));
// show debug console.
// THIS SHOULD ALWAYS BE PRESENT AT THE END OF YOUR SCRIPTS!
// debugging should be controlled by setting the "debug" property to TRUE/FALSE
$db->show_debug_console();
?>