Files
tqw-vanilla/test.php
2025-10-05 22:17:20 +02:00

62 lines
1.5 KiB
PHP

<?php
ini_set("display_errors", "1");
set_include_path( get_include_path().PATH_SEPARATOR. '../library') ;
set_include_path( get_include_path().PATH_SEPARATOR. 'model') ;
require_once 'Zend/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance() ;
spl_autoload_register(function ($class){
$filename="model/$class.php";
if(!file_exists($filename))
{
return "file : $filename is not Exist on the Given Path";
}
require_once "model/$class.php";
});
//Using Zend_Config to pass parameters into Db-connection
$config = new Zend_Config(
array(
'database' => array(
'adapter' => 'Pdo_Mysql',
'params' => array(
'host' => '127.0.0.1',
'dbname' => 'quranicway',
'username' => 'root',
'password' => 'r00t',
)
)
)
);
$db = Zend_Db::factory($config->database);
try {
$db->getConnection() ;
Zend_Db_Table_Abstract::setDefaultAdapter($db);
$countries = new Booking() ;
foreach($countries->getAll() as $values)
{
echo $values['Name']."<br \>";
}
} catch (Zend_Db_Adapter_Exception $e) {
echo "<strong>Database connection failed :</strong>
<ul>
<li>Perhaps a failed login credential, or perhaps the RDBMS is not running</li>
</ul>
" ;
} catch (Zend_Exception $e) {
echo $e->getMessage();
echo "<b>Database connection failed :</b> <br \>
<li>perhaps factory() failed to load the specified Adapter class</li>" ;
}