mercredi 27 avril 2016

How to print list of columns in SQLITE 2 table?

In mysql class I have this method to print list of columns

public function printMemberColumns(){
  $n=-1;
  foreach (explode(',',CONFIG::tables) as $tab):
    $n++;
    $result = mysql_query( "SELECT `COLUMN_NAME` FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE `TABLE_NAME`='$tab' AND `TABLE_SCHEMA`='".MYSQL::BASE."'");    
    while ( $data = mysql_fetch_row($result) )
      echo $data[0];
  endforeach;
  }

How to change it to do it using sqlite?

I would expect something like this but it says these tables do not exist:

public function printMemberColumns(){
  $n=-1;
  foreach (explode(',',CONFIG::tables) as $tab):
    $n++;
    $result = sqlite_query( $this->handle, "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='$tab' AND TABLE_SCHEMA='".SQLITE::BASE."'");    
    while ( $data = sqlite_fetch_array($result) )
      echo $data[0];
  endforeach;
  }

I am not using PDO and I am using PHP 5.2.0

Aucun commentaire:

Enregistrer un commentaire