【发布时间】:2016-08-29 21:11:57
【问题描述】:
我是 cakephp 新手,请帮助我
这是我的控制器代码
public function getCity()
{
$this->autoRender = false;
//$cities = array();
$this->loadModel('City');
//debug($this->request['data']['id']);exit;
if (isset($this->data['id']))
{
$cities = $this->City->find("list",array("conditions"=>array("City.state_id"=>$this->data['id']),"fields"=>array("City.id","City.city_name")));
echo "<pre>";
print_r($cities);
debug($cities);
exit;
echo json_encode($cities);
}
}
这个ajax调用函数的输出如下
<pre>Array(
[509] => Zwickau
[13402] => Adorf, Vogtland
[13552] => Altenberg, Erzgebirge
[15594] => Diera-Zehren
[15646] => Dippoldiswalde
[17924] => Hartmannsdorf bei Chemnitz
[17926] => Hartmannsdorf bei Kirchberg
[18115] => Heinsdorfergrund
[22731] => Rackwitz
[24976] => Tiefenbach, Sachsen
[24995] => Tirpersdorf
[25025] => Torgau
[25062] => Trebendorf bei Wei�wasser
[25067] => Trebsen / Mulde
[25084] => Treuen, Vogtland
[25088] => Triebel / Vogtland
[25090] => Triebischtal
[26669] => Zschorlau
[26690] => Zwenkau
[26691] => Zwickau
[26697] => Zwochau bei Delitzsch
[26698] => Zw�nitz
[26699] => Zwota
[151788] => Raschau-Markersbach )
<div class="cake-debug-output"><span><strong>\app\Controller\SubscribersController.php</strong> (line <strong>919</strong>)</span><pre class="cake-debug"></pre></div>
现在的问题是在 print_r 函数中获取数据,但调试时没有显示该数据...对于 City.city_name 字段,但它在另一个字段中显示数据,例如 populationetc...所以我没有看到这些数据。 ...请帮助我...
【问题讨论】:
-
"Zw�nitz" 表示您的 php 应用程序的编码与数据不同。 CakePHP debug() isn't working but Debugger::dump() is fine 的可能重复项