Code: Select all
require('Zend/Db/Adapter/Pdo/Mysql.php');
class Database {
private $dbh;
public static function connect() {
try {
$dbh = Zend_Db::factory($config->database);
}
catch(Zend_Exception $e) {
echo $e->getMessage();
exit();
}
return $dbh;
}
}and the reason for that is that $config->database is empty.Adapter name must be specified in a string
Now if i type in:
Code: Select all
require('Zend/Db/Adapter/Pdo/Mysql.php');
print_r($config);
class Database {
private $dbh;
public static function connect() {
try {
$dbh = Zend_Db::factory($config->database);
}
catch(Zend_Exception $e) {
echo $e->getMessage();
exit();
}
return $dbh;
}
}but if i put "print_r" inside connect method then "$config" becomes empty.Zend_Config Object ( [_allowModifications:protected] => [_index:protected] => 0 [_count:protected] => 3 [_data:protected] => Array ( [general] => Zend_Config Object ( [_allowModifications:protected] => [_index:protected] => 0 [_count:protected] => 1 [_data:protected] => Array ( [site_title] => Movie Talk ) [_loadedSection:protected] => [_extends:protected] => Array ( ) ) [database] => Zend_Config Object ( [_allowModifications:protected] => [_index:protected] => 0 [_count:protected] => 2 [_data:protected] => Array ( [adapter] => Mysqli [params] => Zend_Config Object ( [_allowModifications:protected] => [_index:protected] => 0 [_count:protected] => 4 [_data:protected] => Array ( [host] => localhost [username] => root [password] => [dbname] => movietalk ) [_loadedSection:protected] => [_extends:protected] => Array ( ) ) ) [_loadedSection:protected] => [_extends:protected] => Array ( ) ) [dir] => Zend_Config Object ( [_allowModifications:protected] => [_index:protected] => 0 [_count:protected] => 4 [_data:protected] => Array ( [root] => E:/PortableApps/WOS/www/MovieTalk_2/ [assets] => E:/PortableApps/WOS/www/MovieTalk_2/public/assets/ [business] => Zend_Config Object ( [_allowModifications:protected] => [_index:protected] => 0 [_count:protected] => 1 [_data:protected] => Array ( [database] => E:/PortableApps/WOS/www/MovieTalk_2/business/Database.class.php ) [_loadedSection:protected] => [_extends:protected] => Array ( ) ) [public] => E:/PortableApps/WOS/www/MovieTalk_2/public/ ) [_loadedSection:protected] => [_extends:protected] => Array ( ) ) ) [_loadedSection:protected] => [_extends:protected] => Array ( ) ) Adapter name must be specified in a string
Why is this happening and how do i fix it?
Thanks.