<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>DBAL Example</title>
</head>
<body>
<h1>DBAL Example</h1>
See the <a href="manual.html">manual</a> for more info.
<pre>
<?php
require("DBAL.Class.php");
$db = null;
try
{
// Create dbal class
// host user password database debug mode debug level
$db = new DBALayer("localhost","SQLUser","SQLPass","SQLDataBase", true , 1 );
}
catch (Exception $e)
{ //Catch exceptions (cannot connect to db etc..)
die ($e->GetMessage());
}
//method 1
echo "Method 1";
$DBTAL = $db->GetDBTAL("Test_Table"); //get dbal table object
$DBTAL->SetDefaultLimit("1"); //Limit the amount of queries returned (optional)
//Select($where,$cols="",$order="",$limit="")\\
$result = $DBTAL->Select("","col1, col2","col1 DESC");
while ($record = mysql_fetch_array($result))
{
var_dump($record);
}
//method 2
echo "Method 2";
$db->SelectTable("Test_Table");
$result = $db->Select("","col1, col2","col1 DESC");
while ($record = mysql_fetch_array($result))
{
var_dump($record);
}
?>
</pre>
</body>
</html>
|