我試圖在查看查詢,執行它並獲得結果。 這是我的嘗試:如何在Zend 1中創建查詢並從查詢中獲取結果?
$last_id = $_COOKIE['last_id'];
//if (isset($last_id)){
$db = new Zend_Db_Table('order_products_names'); //the table name
$query = "select * from order_products_names where order_id = '$last_id'";
$query = $db->query($query);
while ($row = $query->fetch()) {
echo $row['names'];
}
顯然它不起作用。有人可以幫我弄這個嗎 ? 我也試過這個版本:
$db = new Zend_Db_Adapter_Pdo_Mysql(array(
'host' => 'localhost',
'username' => 'lunchbox_live',
'password' => 'xxxxxxxxxxxx',
'dbname' => 'order_products_names',
'adapterNamespace' => 'MyProject_Db_Adapter'
));
$last_id = $_COOKIE['last_id'];
$dbAdapter = Zend_Db_Table::getDefaultAdapter();
$query = $dbAdapter->query("select * from order_products_names where order_id = '$last_id'";
這發生在這行代碼($query = $dbAdapter->query("select * from order_products_names where order_id = '$last_id'";
)的評論: 和發生這種情況時,不評論說:
誰知道zend? – Chester
有沒有你在$ dbAdapter中的東西? – doydoy44
嗨再次@ doydoy44我更新了我的文章,請查看 – Chester