Last active
January 18, 2017 09:31
-
-
Save printminion/e13a33993cfa96fe1e23cb8c7399c92d to your computer and use it in GitHub Desktop.
example of Zend DB call
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $config = new Zend_Config( | |
| array( | |
| 'database' => array( | |
| 'adapter' => 'Pdo_Mysql', | |
| //'adapter' => 'Mysqli', | |
| 'params' => array( | |
| 'host' => 'mysql', | |
| 'dbname' => 'database', | |
| 'username' => 'dev', | |
| 'password' => 'dev', | |
| ) | |
| ) | |
| ) | |
| ); | |
| $db = Zend_Db::factory($config->database); | |
| try { | |
| $db->getConnection(); | |
| } catch (Zend_Db_Adapter_Exception $e) { | |
| // perhaps a failed login credential, or perhaps the RDBMS is not running | |
| } catch (Zend_Exception $e) { | |
| // perhaps factory() failed to load the specified Adapter class | |
| } | |
| $sql = 'SELECT * FROM bugs WHERE bug_id = ?'; | |
| $result = $db->fetchAll($sql, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment