0
I'trying轉換一個簡單的MySQL選擇querys到Zend框架選擇MySQL的選擇轉換爲Zend框架選擇
所以我這樣的:
<?php
$HOST = "localhost";
$USER = "root";
$PASS = "";
$conexion = mysql_connect($HOST,$USER,$PASS) or die("Problemas en la conexion");
mysql_select_db("rapidoypoderosodb",$conexion) or die("Problemas en la seleccion de la base de datos");
mysql_query("SET NAMES 'utf8'");
$sql= "SELECT DISTINCT * FROM especialistas WHERE activo='1'order by estado";
$result=mysql_query($sql);
$options = '<option id="idSelect" value="">seleccione estado...</option>';
while ($row=mysql_fetch_array($result))
{
$estado = $row["estado"];
$options.='<OPTION VALUE="'.$estado.'">'.$estado.'</option>';
}
echo $options;
?>
和我已經轉換:
<?php
global $WHG_DB_HOST, $WHG_DB_USER,$WHG_DB_PASSWD,$WHG_DB_REPLDB;
$db = new Zend_Db_Adapter_Pdo_Mysql(array(
'host' => $WHG_DB_HOST,
'username' => $WHG_DB_USER,
'password' => $WHG_DB_PASSWD,
'dbname' => $WHG_DB_REPLDB
));
$db->query("SET NAMES 'utf8'");
$select = $db->select()
->distinct()
->from(array('e' => 'especialistas'))
->where('e.activo = 1', $VARIABLE)
->order('e.estado');
$result = $db->fetchAll($select);
$options = '<option id="idSelect" value="">seleccione estado...</option>';
foreach($result as $row){
$estado = $row["estado"];
$options.='<OPTION VALUE="'.$estado.'">'.$estado.'</option>';
}
echo $options;
?>
問題是,不工作理論我的index.php給我一個列表來選擇一個選項,並不起作用,爲什麼?