public function getColumnOptions($tableName, $columnName) {
        if (!in_array($this->getColumnType($tableName, $columnName), array('enum', 'set')))
            // only for enum or set columns the options are returned;
            return null;
        $columns = $this->getTableColumns($tableName);
        foreach ($columns as $column) {
            if ($column['Field'] != $columnName)
                continue;
            $options = explode('(', $column['Type'], 2); // get text after (
            $options = substr($options[1], 0, strlen($options[1]) - 1); // and remove ) from the end;
            $options = str_getcsv($options, ',', "'");
            $fOptions = [];
            foreach ($options as $opt){
                $fOptions[$opt] = $opt;
            }
            return $fOptions;
        }
        throw new \Exception("Column `$columnName` not found in table `$tableName`!");
    }
public function getColumnOptions($tableName, $columnName) {
        if (!in_array($this->getColumnType($tableName, $columnName), array('enum', 'set')))
            // only for enum or set columns the options are returned;
            return null;
        $columns = $this->getTableColumns($tableName);
        foreach ($columns as $column) {
            if ($column['Field'] != $columnName)
                continue;
            $options = explode('(', $column['Type'], 2); // get text after (
            $options = substr($options[1], 0, strlen($options[1]) - 1); // and remove ) from the end;
            $options = str_getcsv($options, ',', "'");
            $fOptions = [];
            foreach ($options as $opt){
                $fOptions[$opt] = $opt;
            }
            return $fOptions;
        }
        throw new \Exception("Column `$columnName` not found in table `$tableName`!");
    }
public function getColumnOptions ( $ tableName , $ columnName ) { if ( ! in_array ( $ this -> getColumnType ( $ tableName , $ columnName ) , array ( 'enum' , 'set' ) ) ) // only for enum or set columns the options are returned; return null ; $ columns = $ this -> getTableColumns ( $ tableName ) ; foreach ( $ columns as $ column ) { if ( $ column [ 'Field' ] != $ columnName ) continue ; $ options = explode ( '(' , $ column [ 'Type' ] , 2 ) ; // get text after ( $ options = substr ( $ options [ 1 ] , 0 , strlen ( $ options [ 1 ] ) - 1 ) ; // and remove ) from the end; $ options = str_getcsv ( $ options , ',' , "'" ) ; $ fOptions = [ ] ; foreach ( $ options as $ opt ) { $ fOptions [ $ opt ] = $ opt ; } return $ fOptions ; } throw new \ Exception ( "Column `$columnName` not found in table `$tableName`!" ) ; }
If column exists in table and it's enum or set it will return all available
options. If column exists but it's another type, it will return NULL.
If the column doesn't exist it will trow an Exception;
@param string $tableName
@param string $columnName
@return string[string]|null
@throws \Exception if column is not found
If column exists in table and it s enum or set it will return all available options . If column exists but it s another type it will return NULL . If the column doesn t exist it will trow an Exception ;