无法从查询中获取列值

时间:2015-07-22 12:30:43

标签: php phalcon

我想设置一个文本输入值的数据库值:

<input name="clt_cin_pass" id="clt_cin_pass" type="text" maxlength="25" placeholder="CIN/Passeport" value="{{data.clt_cin_pass}}"/>

data变量来自controller

<?php

use Phalcon\Mvc\Controller;

class ReferentielClientController extends Controller
{
    ...
    public function modifierClientAction($id){
        $this->view->titre = 'Modification de client';
        $critere = array();
        $critere["clt_id"] = $id;
        $enreg = Client::listerClient($critere);
        $this->view->data = $enreg;
        return $this->view->pick("client/client");
    }
    ...
}

?>

模型客户端是:

<?php

use Phalcon\Mvc\Model;
use Phalcon\Mvc\Model\Query;

class Client extends Model {

    function listerClient($critere) {
        // Instantiate the Query
        $sSQL = "
                SELECT c.clt_id as clt_id,c.clt_cin_pass as clt_cin_pass,CONCAT_WS(' ',c.clt_nom,c.clt_prenom) AS noms,c.clt_tel as clt_tel,
                c.clt_adresse as clt_adresse,c.clt_comment as clt_comment 
                FROM client as c WHERE 1 = 1 ";

        if(isset($critere["clt_id"]) && $critere["clt_id"] != "") {
            $sSQL .= "AND c.clt_id = ' " . $critere["clt_id"] . "' ";    
        }

        $query = new Query($sSQL,$this->getDI());

        // Execute the query returning a result if any
        $ret = $query->execute();

        return $ret;

    }
}

?>

查询返回一行,但在运行时该字段没有值!那么如何填充该字段的值?

0 个答案:

没有答案