i am creating restful api, i have created my model in codeignter 4 and in controller when i try to fetch record it gives me this error
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'IS NULL
ORDER BY `id` DESC' at line 3;
am fetching like in controller
$model = new PlacesModel();
$data['places'] = $model->orderBy('id', 'DESC')->findAll();
return $this->respond($data);
i did not mentioned any null or limit then why am getting this ?
I'm Running the following query without any problem in MySQL (5.7.21) Database but this query throws error on my hosting server database which is MariaDB (10.1.47-MariaDB) and I don't have super permission to change the sql mode.
$projects = V2Project::leftJoin('v2_project_locations as v2pl', 'v2pl.project_id', 'v2_projects.id')
->leftJoin('v2_locations as v2l', 'v2l.id', 'v2pl.location_id')
->selectRaw('v2_projects.id, v2_projects.name, group_concat(v2l.name) as locations')
->withDepartmentInMind()
->onlyAuthorizedObjects();
if($by_current_step == true) {
$projects = $projects->where('current_step', 'plan');
}
if($search_val) {
$projects = $projects->whereIn('v2_projects.id', $search_val);
}
$projects = $projects->groupBy('v2_projects.id')->paginate(10);
$projects->appends(Input::except('page', '_token'));
Error:
SQLSTATE[42000]: Syntax error or access violation: 1055 'pm_form_moe.v2_projects.name' isn't in GROUP BY (SQL: select v2_projects.id, v2_projects.name from `v2_projects` group by `v2_projects`.`id`)
I also tried to add every column, but I need the functionality the same as mySQL without adding all columns.
Read about ONLY_FULL_GROUP_BY, then decide what to remove from your SELECT or what to add to the GROUP BY. Don't worry about setting the flag; your code is bad and needs to be fixed. And it was bad in the older version when it did not complain.
(If you show us the generated SQL, we can discuss it further.)
I'm getting up a new server laravel framework, correct the MySQL query to get the data.
Running Laravel 5.6.28, MySql 5.7.21, PHP 7.2.
$query = DB::table('Student a')->select([DB::raw('SQL_CALC_FOUND_ROWS')], 'a.*', b.*')->leftjoin('girls b', 'a.id', '=', 'b.id')->where('a.name', '!=', 'null');
$query->skip($iPagNo)->take($iSwRws);
$sqlPg = $query->get();
print_r($sqlPg);
i have my controller function like this:
private function _send_refund_scores($userId,$scores,$orderId){
$this->loadModel('Score');
$rtn = $this->Score->refund_user_scores($userId,$scores,$orderId);
if(!empty($rtn)){
return true;
}else return false;
}
while in another model Score , I have model function refund_user_scores;
the error like this:
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an
error in your SQL syntax; check the manual that corresponds to your
MySQL server version for the right syntax to use near
'refund_user_scores' at line 1
so,any idea?
I guess you have defined refund_user_scores() as a private function in model Score.
That is why you are getting this error.
Error comes when i run update stored procedure in laravel5 like this..
QueryException in Connection.php line 620:
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Sandeep,09999999999,,,sandeep#gmail.com,,,,,,,)' at line 1 (SQL: call sp_clientupdate(108, Sandeep,09999999999,,,sandeep#gmail.com,,,,,,,))
my code is....
return DB::select('call sp_clientupdate(108, Sandeep,0999999999,,,sandeep#gmail.com,,,,,,,)');
Pls anyone give me solution.....
Try this one,
DB::statement('call sp_clientupdate("108", "Sandeep","0999999999","","","sandeep#gmail.com","","","","","","",)');
It works perfectly.
You change.
return DB::select('call sp_clientupdate("108", "Sandeep","0999999999","","","sandeep#gmail.com","","","","","","",)');
Try it's working perfectly....