|
|||
|
Hi,
This is probably more related to OOP than to databases but here it goes. I've created a seperate class as a wrapper for my database connections. Code:
class jar_database {
public function __construct() {
require_once 'Zend/Db.php';
$params = array ( 'host' => 'localhost',
'username' => 'user',
'password' => 'pw',
'dbname' => 'db');
$db = Zend_Db::factory('PDO_MYSQL', $params);
return $db;
}
}
Code:
$db = new jar_database();
$stmt = $db->query('SELECT * FROM events");
Fatal error: Call to undefined method jar_database::query() I think the problem lies in the way I return the db but I got no real idea how to resolve it. How should I "return" the Zend_Db::factory('PDO_MYSQL', $params)"? Thanks in advance! |
![]() |
| Thread Tools | |
| Display Modes | |
|
|