C3rd
Zend Framwork: Accessing Database in different ways
Posted: 8 May 2012, 13:11pm - TuesdayAssuming I declared some variables in application.ini named webbyConfig and initialized in Bootstrap.php;
$config = Zend_Registry::get('webbyConfig');
$this->_db = new Zend_Db_Adapter_Pdo_Mysql(array(
'host' => $config['db_host'],
'username' => $config['db_user'],
'password' => $config['db_passwd'],
'dbname' => $config['db_name'],
));
....
$sql = 'SELECT a.col1,b.col2 FROM tableA AS a, tableB AS b WHERE a.id = b.id AND a.id = 1';
$stmt = $this->_db->query($sql);
print_r($stmt->fetchAll());
and this is another way accessing the db...
$sql = 'SELECT a.col1,b.col2 FROM tableA AS a, tableB AS b WHERE a.id = b.id AND a.id = 1'; $db = Zend_Db_Table::getDefaultAdapter(); $stmt = $db->query($sql); print_r($stmt->fetchAll());That's what I know so far... I think there's more... still exploring ZF. :)
Search
Categories
Related Links
- Apache Web Server
- ASP Immigration Services Ltd.
- CentOS Linux
- Color Scheme Picker
- CSS Button Generator
- Deviant Art Account
- Don Tabaniag - GraphiCult
- Jerson Maglasang Weblog
- Joshua Manlunas
- Mark "mungkey" Vicente
- Matt Arnilo Baluyos
- MySQL
- Paul Labis
- PHP
- PrendStar
- Ridvan Baluyos
- Scott Davies
- SEO Fart XML-RPC Ping Tool
- Stripes Generator
- The Hero
- Ubuntu Linux
- Vim Carlo Nabora (DA)
- Wella Maria Hong
- What is my IP?
- Xavier University - Ateneo de Cagayan
- Zabyer Community