Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

188
Vistas
How can I fetch records from mysql table in cakephp 3.0 with OR condition?

I want to fetch records from table for names starting with a, b or c but with status=pending in cakephp 3.0. I am trying below query. Please check what is wrong with it as it is also fetching results starting with name '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;
about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Do like below:-

$artists_q = $this->DbArtists->find()->where([
    'album_status' => 'pending',
    'OR' => [['name LIKE' => 'A%'],['name LIKE' => 'B%'],['name LIKE' => 'C%']],
]);

Or you can chek once this too:-

$query = $articles->find()->where(['album_status' => 'pending'])
->orWhere(['name LIKE' => 'A%'])
->orWhere(['name LIKE' => 'B%'])
->orWhere(['name LIKE' => 'C%']);

Reference:- https://book.cakephp.org/3.0/en/orm/query-builder.html

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda