本文整理汇总了PHP中Zend_Db_Adapter_Pdo_Mysql::setFetchMode方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Db_Adapter_Pdo_Mysql::setFetchMode方法的具体用法?PHP Zend_Db_Adapter_Pdo_Mysql::setFetchMode怎么用?PHP Zend_Db_Adapter_Pdo_Mysql::setFetchMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Db_Adapter_Pdo_Mysql
的用法示例。
在下文中一共展示了Zend_Db_Adapter_Pdo_Mysql::setFetchMode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: connectDB
private function connectDB()
{
try {
$dbconfig = array('host' => $this->config->database->host, 'username' => $this->config->database->username, 'password' => $this->config->database->password, 'dbname' => $this->config->database->db);
$dbconfig = $this->doQoolHook('front_pre_connectdb', $dbconfig);
//here we check for database type
switch ($this->config->database->type) {
case "mysql":
$db = new Zend_Db_Adapter_Pdo_Mysql($dbconfig);
$db->getConnection();
$db->setFetchMode(Zend_Db::FETCH_ASSOC);
$smt = $db->query("SET NAMES 'utf8'");
$smt->execute();
break;
case "sqlite":
$db = new Zend_Db_Adapter_Pdo_Sqlite($dbconfig);
$db->getConnection();
$db->setFetchMode(Zend_Db::FETCH_ASSOC);
break;
default:
$db = new Zend_Db_Adapter_Pdo_Mysql($dbconfig);
$db->getConnection();
$db->setFetchMode(Zend_Db::FETCH_ASSOC);
$smt = $db->query("SET NAMES 'utf8'");
$smt->execute();
}
} catch (Zend_Db_Adapter_Exception $e) {
$this->triggerError($this->language['db_connect_error']);
} catch (Zend_Exception $e) {
$this->triggerError($this->language['db_factory_error']);
}
$db = $this->doQoolHook('front_after_connectdb', $db);
$this->db = $db;
}
示例2: connectDB
private function connectDB()
{
$xml = readLangFile('config/config.xml');
setIncludePath(array('special' => array('folder' => $xml->host->folder)));
try {
$dbconfig = array('host' => $xml->database->host, 'username' => $xml->database->username, 'password' => $xml->database->password, 'dbname' => $xml->database->db);
//here we check for database type
switch ($xml->database->type) {
case "mysql":
require_once 'Zend/Db/Adapter/Pdo/Mysql.php';
$db = new Zend_Db_Adapter_Pdo_Mysql($dbconfig);
$db->getConnection();
$db->setFetchMode(Zend_Db::FETCH_ASSOC);
$smt = $db->query("SET NAMES 'utf8'");
$smt->execute();
break;
default:
require_once 'Zend/Db/Adapter/Pdo/Mysql.php';
$db = new Zend_Db_Adapter_Pdo_Mysql($dbconfig);
$db->getConnection();
$db->setFetchMode(Zend_Db::FETCH_ASSOC);
$smt = $db->query("SET NAMES 'utf8'");
$smt->execute();
}
} catch (Zend_Db_Adapter_Exception $e) {
$this->triggerError($this->language['db_connect_error']);
} catch (Zend_Exception $e) {
$this->triggerError($this->language['db_factory_error']);
}
$this->db = $db;
}