【发布时间】:2019-04-21 14:41:00
【问题描述】:
首先,对不起,我的英语不太好。所以我有一个问题,当我显示我的变量时,他返回我 NULL 我不知道为什么:(
标签.php
class Services_Label extends Services_Abstract
{
public function getlibelle()
{
$sRequest = 'SELECT NAME FROM menu WHERE id_application = 2';
$this->executeQueries($sRequest);
$aResult = $this->getAllRows();
$this->freeStatement();
return $aResult;
}
}
IndexController.php
public function indexAction()
{
$oMessage = new Services_Label();
$toto = $oMessage->getlibelle();
$this->view->newMenu12 = $toto;
foreach ($toto as $data) {
foreach($data as $key => $value) {
echo $value[2] . '<br>';
}
}
布局.php
<?php
echo $this->partial('/common/header.phtml', array(
'notshowlogout' => (isset($this->notshowlogout) ? true : false),
'profils' => $this->profils,
'listeHabiUti' => $this->listeHabiUti,
'libmenu' => $this->libmenu,
'userName' => $this->userName,
'siteName' => $this->siteName,
'envName' => $this->envName,
'newMenu12' => $this->newMenu12,
));
?>
header.php
<?php var_dump($this->newMenu12); ?>
答案:空
【问题讨论】:
-
也许您的查询失败了?你的 mysql 会抛出任何错误信息吗?
-
这里面的值是什么:
$toto = $oMessage->getlibelle();? -
SELECT NAME FROM menu WHERE id_application = 2是否返回 0 行? -
查询正常,通常返回 13 行
-
查询在 $toto 值内
标签: php mysql zend-framework