I'm trying to make a raw sql request to get all possible status from an enum column :
public static function getPossibleStatuses(){
$type = DB::select(DB::raw('show columns from defi_user where field = "category";' ))[0]->Type;
preg_match('/^enum((.*))$/', $type, $matches);
$values = array();
foreach(explode(',', $matches[1]) as $value){
$values[] = trim($value, "'");
}
return $values;
}
I'm getting this weird syntax error :
IlluminateDatabaseQueryException
SQLSTATE[HY000]: General error: 1 near "show": syntax error (SQL: show columns from defi_user where field = "category";)
Although i copied the query in every syntax checker I know and they all say it's perfectly valid.
What am I missing ?
Thanks in advance
question from:
https://stackoverflow.com/questions/65863885/sql-returns-syntax-error-from-laravel-raw 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…