Welcome Guest, Not a member yet? Register   Sign In
SQLite3 Field MetaData: $this->db->field_data()
#1

[eluser]Kenzie[/eluser]
I updated the PDO SQLite3 wiki page with these methods:

[h3]Field MetaData functions for SQLite3[/h3]
[h4]pdo_driver.php:[/h4]
Code:
/**
     * Field data query
     *
     * Generates a platform-specific query so that the column data can be retrieved
     *
     * @access public
     * @param string the table name
     * @return string
     */
    function _field_data($table)
    {
        return 'PRAGMA table_info(\'' . $this->escape_table($table) . '\')';
    }
[h4]pdo_result.php:[/h4]
Code:
/**
     * Field data
     *
     * Generates an array of objects containing field meta-data
     *
     * @access public
     * @return array
     */
    function field_data()
    {
        $retval = array();
        $table_info = $this->pdo_results;
        for ($i = 0; $i < count($this->pdo_results); $i++)
        {
            $F                = new stdClass();
            $F->name         = $table_info[$i]['name'];
            $F->type         = $table_info[$i]['type'];
            $F->maxlength    = 0;
            $F->primary_key = $table_info[$i]['pk'];
            $F->default        = $table_info[$i]['dflt_value'];
            //$F->notnull        = $table_info[$i]['notnull'];
            
            $retval[] = $F;
        }
        return $retval;
    }




Theme © iAndrew 2016 - Forum software by © MyBB