CodeIgniter Forums

Full Version: A Database Error Occurred
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
[Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Conversion failed when converting the varchar value 'currInstl + 1' to data type int.

SELECT "custNo", "custName", "totalInstal", "InstallAmnt" FROM "fund" WHERE "status" = 'A' AND "branch" = 16 AND "totalInstal" > 'currInstl + 1' ORDER BY "custName" ASC



Ref (Sql Query works well)
=================
select custNo, custName, totalInstal, InstallAmnt from fund
where status='A' and branch=16 and totalInstal> currInstl+ 1
order by custName;

but not to works in codeigniter..Please help me
@Mohamed,
can you send your PHP code with your sql request?

Perhaps, a problem with your quotes: 'currInstl + 1'
(03-30-2019, 02:54 AM)hc-innov Wrote: [ -> ]@Mohamed,
can you send your PHP code with your sql request?

Perhaps, a problem with your quotes:  'currInstl + 1'

public function getFund()
{
return $this->db->select('custNo, custName, totalInstal, InstallAmnt')
->from('fund')
->where('status', 'A')
->where('branch', 16)
->where('totalInstal >', 'currInstl + 1')
->order_by('custName', 'asc')
->get()
->result_array();
}
You can try this

PHP Code:
public function getFund()
{
return 
$this->db->select('custNo, custName, totalInstal, InstallAmnt')
->
from('fund')
->
where('status''A')
->
where('branch'16)
->
where('totalInstal >''currInstl + 1',false)
->
order_by('custName''asc')
->
get()
->
result_array();

Note the false in where clause for totalInstall <=>The field is not protected (no quote)
(03-30-2019, 11:04 AM)hc-innov Wrote: [ -> ]You can try this

PHP Code:
public function getFund()
{
return 
$this->db->select('custNo, custName, totalInstal, InstallAmnt')
->
from('fund')
->
where('status''A')
->
where('branch'16)
->
where('totalInstal >''currInstl + 1',false)
->
order_by('custName''asc')
->
get()
->
result_array();

Note the false in where clause for totalInstall <=>The field is not protected (no quote)

Thank you so much it's working.. Smile