Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
96 views
in Technique[技术] by (71.8m points)

php - SQL returns syntax error from laravel raw

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...