Welcome Guest, Not a member yet? Register   Sign In
CI 3 QUERY ISSUES
#1
Sad 
(This post was last modified: 05-12-2022, 10:45 PM by SubrataJ.)

Hi there, things were working perfectly untill today's morning , have no idea why it's acting weird,
from a controller type is being sent but its not working for some reason.

PHP Code:
function get_cms_data($type 0$id 0)
 {
 if ((
is_numeric($type)) || ($id && is_numeric($id))) {
 if (
$type) {
 
$this->db->where('type'5);
 }
 if (
$id) {
 
$this->db->where('id'$id);
 }
 
$this->db->limit(1);
 
$query $this->db->get('data_list');

 die(
$this->db->last_query());

 if (
$query->num_rows() > 0) {
 return 
$query->row();
 }
 }else{
 return 
false;
 }
 } 

this is what is being executed. type is coming blank

SELECT * FROM `data_list` WHERE `type` = 'AND ' LIMIT 1
Reply
#2

Hi, die — Equivalent to exit. Maybe that's why. die
Reply
#3

Your if statement is_numeric is returning true for both $type and $id because there set to 0 so both are true.

Check your first if statement logic.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#4

hey thanks for all the help, but There was nothing wrong with my code, It seems there was a malware attack on my server which deleted several files from the project which was causing the issue.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB