douji4948 2014-09-09 02:14
浏览 58
已采纳

使用来自CONCAT和LIKE子句的结果[关闭]

I just want a simple explanation on what does this CONCAT and LIKE does in this code. Thank you.

$data = $this->request->data;
    $conditions = array('authenid' => $data['id'], 'isblacklist' => $data['isblacklist']);

    if( $data['key'] == "msisdn" ) {
        if(isset ($data["search"])){
            if( trim($data["search"]) != "" ) {
                $conditions[ "CONCAT(msisdn,',',ton,',',npi) LIKE" ] = "%".trim($data["search"])."%";
            }
        }
        $tmpData = $this->blkwhtlist_msisdn->find('all', array(
            'conditions' => $conditions
        ));
  • 写回答

1条回答 默认 最新

  • doulin8374 2014-09-09 02:37
    关注

    I guess you are trying querys in mysql db:

    CONCAT is a string function to concatenate in mysql:

    CONCAT('abc', '.de') that return a string 'abc.de'
    

    And the LIKE is a mysql operator used to select data based on patterns. Therefore the LIKE operator is often used in the WHERE clause of the SELECT statement. mysql provides two wildcard characters for using with the LIKE operator, the percentage % and underscore _.

    • The percentage ( %) wildcard allows you to match any string of zero or more characters.
    • The underscore ( _) wildcard allows you to match any single character.
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?