Welcome Guest, Not a member yet? Register   Sign In
Oracle filter with LIKE method always zero result
#1

Hi, Im working with CI and oracle right now but i have difficulties if i use LIKE method.

My code like this :
Code:
$this->db->select('COUNT(*) AS FOUND');
        $this->db->where($where);
        $row = $this->db->get('"ci_r_user_log"')->row();
 And the result is zero for FOUND

I try to look the query and the result like :
Code:
SELECT COUNT(*) AS FOUND FROM "ci_r_user_log" WHERE "ul_datetime_login" LIKE '23-09-2019%'

I try run the query with SQL Developer and get 4 data found. I checked and it's correct.

So why the query that run with CI is not working? But the query is good

Im sorry if my english is bad.
Reply
#2

(This post was last modified: 09-23-2019, 11:42 AM by jreklund.)

Just by the looks of it, try this:
Code:
$this->db->select('COUNT(*) AS FOUND', false);

https://codeigniter.com/user_guide/datab...er::select

And what is $where in this context?

Should be:
Code:
$this->db->like('ul_datetime_login', '23-09-2019', 'after');

Complete code, as ->get() looked wrong too.
Code:
$this->db->select('COUNT(*) AS FOUND', false);
$this->db->like('ul_datetime_login', '23-09-2019', 'after');
$row = $this->db->get('ci_r_user_log')->row();
Reply
#3

@fauzi26,

A suggestion...
I have found that using query bindings ( https://codeigniter.com/user_guide/datab...y-bindings ) is easier and causes me less headaches. My only recommendation is that you be very comfortable with writing queries...
Reply
#4

(09-23-2019, 11:40 AM)jreklund Wrote: Just by the looks of it, try this:
Code:
$this->db->select('COUNT(*) AS FOUND', false);

https://codeigniter.com/user_guide/datab...er::select

And what is $where in this context?

Should be:
Code:
$this->db->like('ul_datetime_login', '23-09-2019', 'after');

Complete code, as ->get() looked wrong too.
Code:
$this->db->select('COUNT(*) AS FOUND', false);
$this->db->like('ul_datetime_login', '23-09-2019', 'after');
$row = $this->db->get('ci_r_user_log')->row();

I try with FALSE but the result is still. The $where is an array contains :
PHP Code:
$where['"ul_datetime_login" LIKE \''.$date.'%\''] = NULL

I used that code because i've try with LIKE and the result is still zero.

->get() code, i follow in the query builder class. I've used for mySQL and postgreSQL DB and it looks fine. But now when i use oracle DB, it doesnt work.
Reply
#5

(09-23-2019, 12:53 PM)php_rocs Wrote: @fauzi26,

A suggestion...
I have found that using query bindings ( https://codeigniter.com/user_guide/datab...y-bindings ) is easier and causes me less headaches.  My only recommendation is that you be very comfortable with writing queries...

I've try to used that, but the result is same. Is something problem with my OCI8 library under xampp maybe? Because i do manually activate the OCI8 library and get the latest library from PECL web
Reply
#6

@fauzi26,

What version of OCI8? What version of PHP? What version of CI?
Reply
#7

(09-24-2019, 11:18 AM)php_rocs Wrote: @fauzi26,

What version of OCI8? What version of PHP? What version of CI?

I used OCI8 2.2.0 from PECL Web , PHP 7.2 and CI 3.1

For additional info, i used XAMPP VC15 and Windows 10 Pro
Reply
#8

@fauzi26,

Have you upgraded anything? Is this the first time that you are having this problem? Did it ever work before?
Reply
#9

(09-25-2019, 08:13 AM)php_rocs Wrote: @fauzi26,

Have you upgraded anything?  Is this the first time that you are having this problem?  Did it ever work before?

I didnt upgrade anything. I usually use mySQL and PostgreSQL, and all work well with my code. And when i used oracle, this things happens.
This is my first time use oracle as my dbms
Reply
#10

@fauzi26,

Can you try running the page with the CI profiler (https://codeigniter.com/user_guide/gener...pplication)? What is the output from it?
Reply




Theme © iAndrew 2016 - Forum software by © MyBB