Quiero obtener registros de la tabla para nombres que comienzan con a, b o c pero con estado = pendiente en cakephp 3.0. Estoy intentando debajo de la consulta. Verifique qué es lo que está mal, ya que también obtiene resultados que comienzan con el nombre 's':
$this->loadModel('DbArtists'); /*** fetching records alphabetically ***/ $artists_q = $this->DbArtists->find()->where(['album_status' => 'pending'])->orWhere(['name ' => 'A%', 'name ' => 'B%', 'name' => 'C%']); $artist = $artists_q->all(); echo "<pre>";print_r($artist);die;Haz lo siguiente: -
$artists_q = $this->DbArtists->find()->where([ 'album_status' => 'pending', 'OR' => [['name LIKE' => 'A%'],['name LIKE' => 'B%'],['name LIKE' => 'C%']], ]);O puede verificar una vez esto también: -
$query = $articles->find()->where(['album_status' => 'pending']) ->orWhere(['name LIKE' => 'A%']) ->orWhere(['name LIKE' => 'B%']) ->orWhere(['name LIKE' => 'C%']);Referencia:- https://book.cakephp.org/3.0/en/orm/query-builder.html