• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Query Builder "FROM * table AS a"

#1
How do you do that in code igniter? I have this Stored Procedure that I want to reproduce in Codeigniter's Query Builder. Thanks in advance guys!

Code:
DELIMITER //

CREATE PROCEDURE get_reports(
IN record_start INT,
IN records_to_retrieve INT
)
BEGIN
   
   DECLARE r_start INT DEFAULT 0;
   DECLARE r_retrieve INT DEFAULT 0;
   SET r_start = record_start - 1;
   SET r_retrieve = record_start * records_to_retrieve;
   
   SELECT a.id,
           b.id AS employee_id,
           CONCAT(b.last_name, ", ", b.first_name, " ", b.middle_name) AS full_name,
           c.id AS machine_id,
           c.title AS machine,
           d.title AS hstatus,
           a.created_on,
           a.action_on,
           a.edit_on,
           a.problems_encountered,
           a.corrective_action,
           a.root_caused,
           a.remarks,
           a.item_replaced
   FROM reports AS a
   INNER JOIN employees AS b ON b.id = a.employee_id
   INNER JOIN machines AS c ON c.id = a.machine_id
   INNER JOIN hstatus AS d ON d.id = a.hstatus_id
   LIMIT r_start , r_retrieve;

END //

DELIMITER ;

This does not work, Stackoverflow said that the LIMIT clause doesn't take parameters only on new versions... How do I see my MySql version in my phpadmin?
Reply

#2
I got it working.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2017 MyBB Group.