我是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
字段的数据...但它显示了另一个字段中的数据,如population
等...所以我没有得到这个视野中的数据....请帮助我...
答案 0 :(得分:0)
在你做公关之前,你可以这样写:
Configure::write('debug', 2); // Check if it's set to 0.
如果为0,则进行以下修改:
转到Config / core.php并将debug的值设为2。
(?>=([0-9A-F]{2}))|(.)