Reputation: 61
I have this code in my model:
$this->db->where('transaction_income_barcode.barcode_number', $barcode_number);
The value of $barcode_number
is 000500007301000005304778
So I compare using PHP it is the correct value:
if($_POST['barcode_number'] == '000500007301000005304778')
but somehow via the model it is not working correctly.
Any ideas?
Upvotes: 1
Views: 89
Reputation: 20473
Forget all the chatter of var_dump()
or complicated last_query()
, simply follow the CI process of profiling your code and add:
$this->output->enable_profiler(TRUE);
In your controller after the active call. This will show you your FULL SQL QUERY
(actually, all queries on that page).
Cleanest way to go about it, my suspicion is that your value is being converted to a int
and it STRIPS out the leading 000
's
Take care of that by doing a cast:
$this->db->where('transaction_income_barcode.barcode_number', (string)$barcode_number );
As a side note:
Don't use $_POST['barcode_number']
instead be safe with CI's $this->input->post('barcode_number');
Upvotes: 1