Ejemplo n.º 1
0
 /**
  * Get a list of names of the table in a database
  * @param Database $database
  * @return string[]
  */
 public function getTables(Database $database)
 {
     // Cache the list of tables
     if (!isset($this->tableNames[$database->getName()])) {
         $this->tableNames[$database->getName()] = [];
         $tables = $this->fetchAll("SELECT name, object_id FROM sys.objects WHERE type IN ('U ', 'V ')", [], 'object_id');
         $offset = strlen($database->getPrefix());
         foreach ($tables as $index => $row) {
             $this->tableNames[$database->getName()][$index] = substr(current($row), $offset);
         }
     }
     return $this->tableNames[$database->getName()];
 }
Ejemplo n.º 2
0
 /**
  * Get a list of names of the table in a database
  * @param Database $database
  * @return string[]
  */
 public function getTables(Database $database)
 {
     // Cache the list of tables
     if (!isset($this->tableNames[$database->getName()])) {
         $this->tableNames[$database->getName()] = [];
         $tables = $this->fetchAll("SHOW TABLES FROM `{$database->getName()}` LIKE ?", ["{$database->getPrefix()}%"]);
         $offset = strlen($database->getPrefix());
         foreach ($tables as $row) {
             $this->tableNames[$database->getName()][] = substr(current($row), $offset);
         }
     }
     return $this->tableNames[$database->getName()];
 }