Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

179
Views
¿Cómo selecciono de la tabla con la condición DONDE y el orden de desc usando la función de creación de consultas?

Estoy tratando de seleccionar comentarios en mi tabla de Comments . Y quiero seleccionarlos en función de un Número de informe y en orden descendente utilizando las funciones del generador de consultas codeigniter 3.

Obtuve este código aquí en mi modelo y si var_dump simplemente no funciona de la manera que quiero. este es el código que tengo hasta ahora:

 $this->db->order_by('Date', 'DESC'); $query=$this->db->where("Comments", array('ReportNum' => $report)); $row=$query->result();

Esto es lo que obtengo cuando lo var_dump :

 object(CI_DB_mysqli_result)#27 (8) { ["conn_id"]=> object(mysqli)#16 (18) { ["affected_rows"]=> int(5) ["client_info"]=> string(13) "mysqlnd 8.0.9" ["client_version"]=> int(80009) ["connect_errno"]=> int(0) ["connect_error"]=> NULL ["errno"]=> int(0) ["error"]=> string(0) "" ["error_list"]=> array(0) { } ["field_count"]=> int(5) ["host_info"]=> string(25) "Localhost via UNIX socket" ["info"]=> NULL ["insert_id"]=> int(0) ["server_info"]=> string(21) "5.5.5-10.4.20-MariaDB" ["server_version"]=> int(100420) ["sqlstate"]=> string(5) "00000" ["protocol_version"]=> int(10) ["thread_id"]=> int(571) ["warning_count"]=> int(0) } ["result_id"]=> object(mysqli_result)#26 (5) { ["current_field"]=> int(0) ["field_count"]=> int(5) ["lengths"]=> NULL ["num_rows"]=> int(5) ["type"]=> int(0) } ["result_array"]=> array(0) { } ["result_object"]=> array(5) { [0]=> object(stdClass)#28 (5)

^ esto viene antes de la matriz deseada.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Necesita una cláusula get para consultar una tabla; puedes usar:

where() y get() :

 $this->db->order_by('Date', 'DESC'); $this->db->where( array('ReportNum' => $report)); $query=$this->db->get("Comments"); $row=$query->result();

o get_where() :

 $this->db->order_by('Date', 'DESC'); $query=$this->db->get_where("Comments", array('ReportNum' => $report)); $row=$query->result();

Acerca del generador de consultas de CI 3.x.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!