Created
September 13, 2012 22:33
-
-
Save scragg0x/3718213 to your computer and use it in GitHub Desktop.
PHP Autoload and connect script example
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 | |
set_include_path('/usr/share/php/libzend-framework-php/'. PATH_SEPARATOR . "."); | |
function __autoload($className) { | |
require $className = str_replace('_', '/', $className) . '.php'; | |
} | |
$db = new Zend_Db_Adapter_Mysqli(array('host'=>'localhost', 'username'=>'', 'password'=>'', 'dbname'=>'')); | |
/* Example Usage */ | |
/* | |
$sql = "SELECT * FROM some_table WHERE id = ? LIMIT 1"; | |
$db->fetchRow($sql, $id); | |
$sql = "SELECT * FROM some_table LIMIT 100"; | |
$db->fetchAll($sql); | |
foreach($rows as $row){ | |
print_r($row); | |
} | |
$sql = "UPDATE some_table SET foo = ? WHERE id = ? LIMIT 1"; | |
$db->query($sql, array($foo, $id)); | |
*/ | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment