public function getCols($types = false)
    {
        $schema = $this->db->schema($this->name, null, 0);
        if (!$types)
            return array_keys($schema);
        else
            foreach ($schema as $name => &$cols) {
                $default = ($cols['default'] === '') ? null : $cols['default'];
                if (!is_null($default) && ((is_int(strpos($curdef=strtolower(
                    $this->findQuery($this->schema->defaultTypes['CUR_STAMP'])),
                    strtolower($default))) || is_int(strpos(strtolower($default),$curdef)))
                    || $default == "('now'::text)::timestamp(0) without time zone"))
                {
                    $default = 'CUR_STAMP';
                } elseif (!is_null($default)) {
                    // remove single-qoutes
                    if (preg_match('/sqlite2?/', $this->db->driver()))
                        $default=preg_replace('/^\s*([\'"])(.*)\1\s*$/','\2',$default);
                    elseif (preg_match('/mssql|sybase|dblib|odbc|sqlsrv/', $this->db->driver()))
                        $default=preg_replace('/^\s*(\(\')(.*)(\'\))\s*$/','\2',$default);
                    // extract value from character_data in postgre
                    elseif (preg_match('/pgsql/', $this->db->driver()))
                        if (is_int(strpos($default, 'nextval')))
                            $default = null; // drop autoincrement default
                        elseif (preg_match("/^\'*(.*)\'*::(\s*\w)+/", $default, $match))
                            $default = $match[1];
                } else
                    $default=false;
                $cols['default'] = $default;
            }
        return $schema;
    }
public function getCols($types = false)
    {
        $schema = $this->db->schema($this->name, null, 0);
        if (!$types)
            return array_keys($schema);
        else
            foreach ($schema as $name => &$cols) {
                $default = ($cols['default'] === '') ? null : $cols['default'];
                if (!is_null($default) && ((is_int(strpos($curdef=strtolower(
                    $this->findQuery($this->schema->defaultTypes['CUR_STAMP'])),
                    strtolower($default))) || is_int(strpos(strtolower($default),$curdef)))
                    || $default == "('now'::text)::timestamp(0) without time zone"))
                {
                    $default = 'CUR_STAMP';
                } elseif (!is_null($default)) {
                    // remove single-qoutes
                    if (preg_match('/sqlite2?/', $this->db->driver()))
                        $default=preg_replace('/^\s*([\'"])(.*)\1\s*$/','\2',$default);
                    elseif (preg_match('/mssql|sybase|dblib|odbc|sqlsrv/', $this->db->driver()))
                        $default=preg_replace('/^\s*(\(\')(.*)(\'\))\s*$/','\2',$default);
                    // extract value from character_data in postgre
                    elseif (preg_match('/pgsql/', $this->db->driver()))
                        if (is_int(strpos($default, 'nextval')))
                            $default = null; // drop autoincrement default
                        elseif (preg_match("/^\'*(.*)\'*::(\s*\w)+/", $default, $match))
                            $default = $match[1];
                } else
                    $default=false;
                $cols['default'] = $default;
            }
        return $schema;
    }
public function getCols ( $ types = false ) { $ schema = $ this -> db -> schema ( $ this -> name , null , 0 ) ; if ( ! $ types ) return array_keys ( $ schema ) ; else foreach ( $ schema as $ name => & $ cols ) { $ default = ( $ cols [ 'default' ] === '' ) ? null : $ cols [ 'default' ] ; if ( ! is_null ( $ default ) && ( ( is_int ( strpos ( $ curdef = strtolower ( $ this -> findQuery ( $ this -> schema -> defaultTypes [ 'CUR_STAMP' ] ) ) , strtolower ( $ default ) ) ) || is_int ( strpos ( strtolower ( $ default ) , $ curdef ) ) ) || $ default == "('now'::text)::timestamp(0) without time zone" ) ) { $ default = 'CUR_STAMP' ; } elseif ( ! is_null ( $ default ) ) { // remove single-qoutes if ( preg_match ( '/sqlite2?/' , $ this -> db -> driver ( ) ) ) $ default = preg_replace ( '/^\s*([\'"])(.*)\1\s*$/' , '\2' , $ default ) ; elseif ( preg_match ( '/mssql|sybase|dblib|odbc|sqlsrv/' , $ this -> db -> driver ( ) ) ) $ default = preg_replace ( '/^\s*(\(\')(.*)(\'\))\s*$/' , '\2' , $ default ) ; // extract value from character_data in postgre elseif ( preg_match ( '/pgsql/' , $ this -> db -> driver ( ) ) ) if ( is_int ( strpos ( $ default , 'nextval' ) ) ) $ default = null ; // drop autoincrement default elseif ( preg_match ( "/^\'*(.*)\'*::(\s*\w)+/" , $ default , $ match ) ) $ default = $ match [ 1 ] ; } else $ default = false ; $ cols [ 'default' ] = $ default ; } return $ schema ; }
get columns of a table
@param bool $types
@return array
get columns of a table