The zf framework's db class select querier join linked lists use the example of zend framework
- 2021-01-25 07:22:03
- OfStack
Example use of the zend framework's query join() linked list
<?php
// The introduction of Loader class ( Autoload classes )
require_once("Zend/Loader.php");
// use Loader Classes introduce 1 a Db class
Zend_Loader::loadClass("Zend_Db");
// The introduction of Zend_Db The state of the machine
Zend_Loader::loadClass("Zend_Db_Statement_Pdo");
// Configure database connection information
$Config = array('host' => '127.0.0.1' ,
'username' => 'root' ,
'password' => '111' ,
'dbname' => 'test',
'profiler' => "true"
);
// tell Zend_Db Class operates on the database and database configuration information
$Db = Zend_Db::factory('PDO_Mysql' , $Config);
// Execute the encoding statement
$Db -> query("set names utf8");
//-----------------------------------------------
$Select = $Db ->select();
$Select -> from('sanguo','*');
$Select -> join('dengji','sanguo.s_dengji = dengji.d_id');
$Select -> order('s_dengji asc');
$Reslut = $Db -> fetchAll($Select);
echo "<table border='1' width='600' style='text-align:center'>";
foreach ($Reslut as $key => $value)
{
echo "<tr>";
foreach ($value as $key2 => $value2)
{
echo "<td>" . $value2 . "</td>";
}
echo "</tr>";
}
echo "</table>";
?>