Reputation: 65
I have tested with two types 1)
DB::statement('call abc_cmw("$ipaddress","$cname","$recvd_date","$language","$address1","$address2","$address3","$pincode","$mobileno","$amobileno","$email_address","$idproofdetail","$Description","$remedies","$gretype","$fcount","$content1","$content2","$district_problem","$city_problem", "$block_problem","$village_problem","$username","$sugg_demand","$dept_name","$indiv_grp","$ac_problem")');
2)
DB::select('exec abc_cmw("$ipaddress","$cname","$recvd_date","$language","$address1","$address2","$address3","$pincode","$mobileno","$amobileno","$email_address","$idproofdetail","$Description","$remedies","$gretype","$fcount","$content1","$content2","$district_problem","$city_problem", "$block_problem","$village_problem","$username","$sugg_demand","$dept_name","$indiv_grp","$ac_problem")');
but both ways have same error
QueryException in Connection.php line 647: SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "call" LINE 1: call abc_cmw("$ipaddress","$cname","$re... ^ (SQL: call abc_cmw("$ipaddress","$cname","$recvd_date","$language","$address1","$address2","$address3","$pincode","$mobileno","$amobileno","$email_address","$idproofdetail","$Description","$remedies","$gretype","$fcount","$content1","$content2","$district_problem","$city_problem", "$block_problem","$village_problem","$username","$sugg_demand","$dept_name","$indiv_grp","$ac_problem"))
Upvotes: 0
Views: 1951
Reputation: 3826
In PostgreSQL functions are called using SELECT
clause, e.g.: SELECT func()
You should avoid inserting SQL parameters directly because of the possibility of SQL injections. Use bindings instead:
DB::statement('SELECT abc_cmw(?, ?, ?)', [$param1, $param2, $param3]);
or
DB::statement('SELECT abc_cmw(:param1, :param2, :param3)', [
'param1' => $param1,
'param2' => $param2,
'param3' => $param3
]);
Upvotes: 2