CodeIgniter Forums
CI4 SQLite3 getFieldData() always returns field type 5 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forum-28.html)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forum-30.html)
+--- Thread: CI4 SQLite3 getFieldData() always returns field type 5 (/thread-68311.html)



CI4 SQLite3 getFieldData() always returns field type 5 - qury - 06-22-2017

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();
 
    $db->initialize();
 
    $sql 'select col1,col1 from table';
 
    $query $db->execute($sql);
 
    $query->columnType(0);
 
  
     $retval   
= [];
 
   
    for 
($i 1$c $this->numColumns(); $i $c$i++)
 
   {
 
   $col=$i-1;
 
   $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