Welcome Guest, Not a member yet? Register   Sign In
CI4 SQLite3 getFieldData() always returns field type 5

(This post was last modified: 06-22-2017, 02:56 PM by qury.)

Hi Guys,

I've decided to play around with porting the sqlite3 driver from CI3 to CI4, however i got stuck with the getFieldData() function.

The below pulls the field types correctly in my controller:
PHP Code:
    $db = \Config\Database::connect();
    $sql 'select col1,col1 from table';
    $query $db->execute($sql);
= [];
($i 1$c $this->numColumns(); $i $c$i++)
   $retval[$col  $query->columnType($i);

However the below query in my Result.php does not to return the correct numeric representation of the data types rather it is 5 for everything, all the time.

It is like $this->resultID is somehow altered and is not the actual result object?

PHP Code:
  $retval = [];

       for ($i 0$c $this->getFieldCount(); $i $c$i++)
           $retval[$i      = new \stdClass();
           $retval[$i]->name $this->resultID->columnName($i);

           $type                   $this->resultID->columnType($i);
           //  $retval[$i]->type = isset($data_types[$type]) ? $data_types[$type] : $type;
           $retval[$i]->type       $type;
           $retval[$i]->max_length NULL;

ps: i'm still learning how Ci4 works, so go easy on me Wink

Theme © iAndrew 2016 - Forum software by © MyBB