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

336
Vistas
codeigniter4 countAllResults() empty string

in version 4.0.4 of codeigniter it does not give me an error but in version 4.1.3 it gives me an error

public function verificar($email, $cedula)
{
    $query = $this->db->table('veterinario AS v');
    $query->select('v.*');
    $query->where('v.email', $email);
    $query->where('v.cedula', $cedula);
    $querys = $query->get()->getResult();

    var_dump($querys);

    if (!empty($querys)) {
        if ($query->countAllResults() == 1) {
            echo 'encontrado';
        } else {
            echo 'noencontrado';
        }
    } else {
        echo 'noencontrado';
    }
}

example

until the var_dump I check and if it brings me the data from the database but when entering the if it tells me that empty string or it goes straight to the not found

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You could use the helper function count.

Replace the countAllResults with the count function like $query->countAllResults() == 1 into count($querys) == 1.

It returns the number of rows returned by the query. You can use it like this:

public function verificar($email, $cedula)
{
    $query = $this->db->table('veterinario AS v');
    $query->select('v.*');
    $query->where('v.email', $email);
    $query->where('v.cedula', $cedula);
    $querys = $query->get()->getResult();

    var_dump($querys);

    if (!empty($querys)) {
        if (count($querys) == 1) {
            echo 'encontrado';
        } else {
            echo 'noencontrado';
        }
    } else {
        echo 'noencontrado';
    }
}
over 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