Pages

Tuesday, December 15, 2020

Return list of databases for use in dropdown

public function getdbnames() {
 $pdo = $this->db;
 
 try{
  $query1 = $pdo->query('SHOW DATABASES' );
  $dbs = $query1->result_array();
  // var_dump($dbs);
  foreach ($dbs as $row) {
     foreach ($row as $key => $value) {
      if ($value <>"information_schema" && $value <>"mysql" && $value <>"sys" ) {
       $dblist[]= "$value";
       # code...
      }
     }
  }
   return $dblist;

 }
 catch(PDOException $e) {
  die("Could not get result");
 }
 
}

View code

No comments:

Post a Comment