Created
January 30, 2011 08:00
-
-
Save marcinwol/802673 to your computer and use it in GitHub Desktop.
Example of using Zend_Db independent from Zend Application
This file contains 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 | |
#index.php | |
// Assuming the Following directory structures | |
// | |
// |-- index.php | |
// `-- library | |
// `-- Zend | |
// |-- Db | |
// |-- Db.php | |
// |-- Loader | |
// |-- Loader.php | |
// `-- Exception.php | |
// Ensure library/ is on include_path | |
set_include_path(implode(PATH_SEPARATOR, array( | |
realpath('./library'), | |
get_include_path(), | |
))); | |
// Register autoloader | |
require_once('library/Zend/Loader/Autoloader.php'); | |
Zend_Loader_Autoloader::getInstance(); | |
// Get Db adapter | |
$db = Zend_Db::factory('pdo_mysql', array( | |
'host' => '127.0.0.1', | |
'username' => 'someUsername', | |
'password' => 'somePassword', | |
'dbname' => 'databaseName')); | |
// En example query | |
$stml = $db->query('select * from SOME_TABLE'); | |
var_dump($stml->fetchAll()); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment