Adsense
Popular Posts
- Code update from PHP 7.4 to PHP 8.1 - PhpSpreadsheet
- MySQL workbench -"Could not decrypt password cache"
- Code update from PHP 7.4 to PHP 8.1 - Worksheet/Iterator.php
- Rendering HTML tags inside textarea
- axios handle blob type data
- Unix Utils and wget in Windows
- increase mysql query speed
- Setup vi syntax for PHP
- Get WAMP running on EC2
- EXCEL return to the next line in the same cell
Tuesday, February 8, 2022
Laravel: get enum values of a column in MySQL table
public function get_enum_values($table, $field){
$enum = [];
$test=DB::select(DB::raw("show columns from {$table} where field = '{$field}'"));
if(!empty($test)){
preg_match('/^enum\((.*)\)$/', $test[0]->Type, $matches);
foreach( explode(',', $matches[1]) as $value )
{
$enum[] = trim( $value, "'" );
}
}
return $enum;
}
Labels:
Laravel
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment