Studyon Minte9.com
ZF 1.0

Study

Adapter



1) Connecting

$db = Zend_Db::factory('PDO_MYSQL', array(
	'host'		=> 'localhost',
	'username'	=> 'root',
	'password'	=> '',
	'dbname'	=> 'zfsite',
	'port'		=> '3306'
));
$db->query('SET NAMES utf8');
$db->setFetchMode(Zend_Db::FETCH_OBJ);
Zend_Db_Table::setDefaultAdapter($db);
Zend_Registry::set('dbAdapter', $db);


2) Usage

$db = Zend_Registry::get('dbAdapter');
$sql = "SELECT * FROM article";
$db->fetchAll($sql);


http://framework.zend.com/manual/en/zend.db.adapter.html