Skip to content

Instantly share code, notes, and snippets.

@marcinwol
Created January 30, 2011 08:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcinwol/802673 to your computer and use it in GitHub Desktop.
Save marcinwol/802673 to your computer and use it in GitHub Desktop.
Example of using Zend_Db independent from Zend Application
<?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