mysql - Laravel adding parameter with raw queries using Like operators and '%" -


i did ways assign parameter it's not working

here code:

$sqldefault = "select * histories h h.status % :status %";  return db::select(db::raw($sqldefault), ['status' => $status]); 

it's not working try ways assign:

'%:status%' or '%':status'%'

but it's not work

now don't use parameter , it's worked perfectlly

$sqldefault = "select * histories h h.status '%$status%'";

the question how can use parameter when using operator "%" ?

replace $status '%'.$status.'%'

$sqldefault = "select * histories h h.status  :status ";  return db::select(db::raw($sqldefault,['status' => '%'.$status.'%'])); 

or use select only:

return  = db::select(sqldefault , ['status' => '%'.$status.'%']); 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

.htaccess - ERR_TOO_MANY_REDIRECTS htaccess -