$db = Zend_Db_Table_Abstract::getDefaultAdapter()
$db->fetchAll("select * from table_name")
$cid= (int) $this->_request->getParam('cid')
$cname = $this->_request->getParam('cname')
$db = Zend_Db_Table_Abstract::getDefaultAdapter()
$db->fetchAll("select * from table_name where cname like %". $db->quote($cname)."% and cid=".$cid)
需要对参数添加引号防止sql攻击。
需要对多数据库配置;设置一个为默认的。您可以这样写:foreach ($config->db as $config_name =>$db) {
$dbAdapters[$config_name] = Zend_Db::factory($db->adapter, $db->toArray())
if($db->adapter != "SQLSRV")
{
$dbAdapters[$config_name]->query("SET NAMES 'utf8'")
}
//self::$registry->database = $dbAdapters[$config_name]
if((boolean)($db->default))
Zend_Db_Table::setDefaultAdapter ($dbAdapters[$config_name])
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)