FuelPHP Bin
SELECT `t0`.`problem_description` AS `t0_c0`, `t0`.`device_status_description` AS `t0_c1`, `t0`.`solution_description` AS `t0_c2`, `t0`.`services_price` AS `t0_c3`, `t0`.`id` AS `t0_c4`, `t0`.`customer_id` AS `t0_c5`, `t0`.`accepting_technician_id` AS `t0_c6`, `t0`.`technician_id` AS `t0_c7`, `t0`.`branch_id` AS `t0_c8`, `t0`.`customer_device_id` AS `t0_c9`, `t0`.`refurbishing_id` AS `t0_c10`, `t0`.`status_id` AS `t0_c11`, `t0`.`sms_sent` AS `t0_c12`, `t0`.`created_at` AS `t0_c13`, `t0`.`updated_at` AS `t0_c14`, `t1`.`status_name` AS `t1_c0`, `t1`.`is_finished` AS `t1_c1`, `t1`.`colour` AS `t1_c2`, `t1`.`id` AS `t1_c3`, `t2`.`category_id` AS `t2_c0`, `t2`.`company_id` AS `t2_c1`, `t2`.`first_name` AS `t2_c2`, `t2`.`last_name` AS `t2_c3`, `t2`.`id_number` AS `t2_c4`, `t2`.`address` AS `t2_c5`, `t2`.`address_city` AS `t2_c6`, `t2`.`address_zip` AS `t2_c7`, `t2`.`email` AS `t2_c8`, `t2`.`phone1` AS `t2_c9`, `t2`.`phone2` AS `t2_c10`, `t2`.`id` AS `t2_c11`, `t3`.`customer_id` AS `t3_c0`, `t3`.`device_id` AS `t3_c1`, `t3`.`device_serial_number` AS `t3_c2`, `t3`.`id` AS `t3_c3`, `t4`.`device_model` AS `t4_c0`, `t4`.`manufacturer_id` AS `t4_c1`, `t4`.`category_id` AS `t4_c2`, `t4`.`id` AS `t4_c3`, `t5`.`manufacturer_name` AS `t5_c0`, `t5`.`id` AS `t5_c1`, `t6`.`branch_name` AS `t6_c0`, `t6`.`branch_address` AS `t6_c1`, `t6`.`branch_city` AS `t6_c2`, `t6`.`id` AS `t6_c3`, `t7`.`username` AS `t7_c0`, `t7`.`email` AS `t7_c1`, `t7`.`group_id` AS `t7_c2`, `t7`.`password` AS `t7_c3`, `t7`.`last_login` AS `t7_c4`, `t7`.`previous_login` AS `t7_c5`, `t7`.`login_hash` AS `t7_c6`, `t7`.`user_id` AS `t7_c7`, `t7`.`created_at` AS `t7_c8`, `t7`.`updated_at` AS `t7_c9`, `t7`.`id` AS `t7_c10`, `t8`.`user_id` AS `t8_c0`, `t8`.`created_at` AS `t8_c1`, `t8`.`updated_at` AS `t8_c2`, `t8`.`id` AS `t8_c3`, `t8`.`parent_id` AS `t8_c4`, `t8`.`key` AS `t8_c5`, `t8`.`value` AS `t8_c6`, `t9`.`spare_serial_number` AS `t9_c0`, `t9`.`price` AS `t9_c1`, `t9`.`id` AS `t9_c2`, `t9`.`work_order_id` AS `t9_c3`, `t9`.`spare_id` AS `t9_c4` FROM (SELECT `t0`.`problem_description`, `t0`.`device_status_description`, `t0`.`solution_description`, `t0`.`services_price`, `t0`.`id`, `t0`.`customer_id`, `t0`.`accepting_technician_id`, `t0`.`technician_id`, `t0`.`branch_id`, `t0`.`customer_device_id`, `t0`.`refurbishing_id`, `t0`.`status_id`, `t0`.`sms_sent`, `t0`.`created_at`, `t0`.`updated_at` FROM `work_orders` AS `t0` ORDER BY `t0`.`id` DESC LIMIT 50 offset 0) AS `t0` LEFT JOIN `work_order_status` AS `t1` ON ( `t0`.`status_id` = `t1`.`id` ) LEFT JOIN `customers` AS `t2` ON ( `t0`.`customer_id` = `t2`.`id` ) LEFT JOIN `customer_devices` AS `t3` ON ( `t0`.`customer_device_id` = `t3`.`id` ) LEFT JOIN `devices` AS `t4` ON ( `t3`.`device_id` = `t4`.`id` ) LEFT JOIN `device_manufacturers` AS `t5` ON ( `t4`.`manufacturer_id` = `t5`.`id` ) LEFT JOIN `branches` AS `t6` ON ( `t0`.`branch_id` = `t6`.`id` ) LEFT JOIN `users` AS `t7` ON ( `t0`.`technician_id` = `t7`.`id` ) LEFT JOIN `users_metadata` AS `t8` ON ( `t7`.`id` = `t8`.`parent_id` ) LEFT JOIN `work_order_spares` AS `t9` ON ( `t0`.`id` = `t9`.`work_order_id` ) WHERE ( ( `t0`.`branch_id` IN ( 1, 2, 3, 4, 5, 6, 7, 8 ) AND ( `t2`.`first_name` LIKE '%%' OR `t2`.`last_name` LIKE '%%' OR `t5`.`manufacturer_name` LIKE '%%' OR `t4`.`device_model` LIKE '%%' OR `t8`.`value` LIKE '%%' OR `t1`.`status_name` LIKE '%%' ) ) OR `t0`.`id` = '' ) ORDER BY `t0`.`id` DESC