Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
鉴于此查询,我如何在 LIKE 条件下使用 bindValue(:name, $name) 进行通配符搜索:
$post = Yii::$app->db->createCommand('SELECT * FROM fruits WHERE name LIKE %:name%') ->bindValue(':name', 'apple') ->queryOne();
我这样做了,它按我的需要做。
$post = Yii::$app->db->createCommand('SELECT * FROM fruits WHERE name LIKE :name') ->bindValue(':name', '%apple%') ->queryOne();