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.
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 vmware exsi重置后登不上
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?
  • ¥15 电磁场的matlab仿真
  • ¥15 mars2d在vue3中的引入问题
  • ¥50 h5唤醒支付宝并跳转至向小荷包转账界面