【问题标题】:Search similar results搜索类似结果
【发布时间】:2013-08-17 19:54:27
【问题描述】:

在我的数据库中,我将有大学建筑房间(例如 B100、A200、TLAB100),我希望它这样当人们搜索特定房间(例如 B101、B102)时,它会返回不带结束数字,所以:B100。

到目前为止,我的控制器如下所示:

$results = $this->Building->find('all', array(
    'conditions' => array(
        'Building.building LIKE' => $this->data['Food']['q']
        )
    )
);

但我相信 LIKE 不是正确的命令。因为它不是那样工作的

【问题讨论】:

    标签: php sql cakephp


    【解决方案1】:

    为什么 Like 不对?

    $likeSmth = substr($this->data['Food']['q'], 0, -1);
    'SELECT * FROM tbl  WHERE roomnumber LIKE '.$likeSmth.'%'
    

    等等

    【讨论】:

      猜你喜欢
      • 2014-08-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多