Database::tableExists PHP Method

tableExists() public method

public tableExists ( $table ) : boolean
return boolean
    public function tableExists($table)
    {
        $table = $this->addIdentifierQuotes($table);
        $prev = $this->ignoreErrors(true);
        $response = $this->doQuery("SELECT 1 FROM {$table} LIMIT 1;");
        $this->ignoreErrors($prev);
        return (bool) $response;
    }

Usage Example

Example #1
0
 /**
  * Determine whether an existing installation of MediaWiki is present in
  * the configured administrative connection. Returns true if there is
  * such a wiki, false if the database doesn't exist.
  *
  * Traditionally, this is done by testing for the existence of either
  * the revision table or the cur table.
  *
  * @return bool
  */
 public function needsUpgrade()
 {
     $status = $this->getConnection();
     if (!$status->isOK()) {
         return false;
     }
     if (!$this->db->selectDB($this->getVar('wgDBname'))) {
         return false;
     }
     return $this->db->tableExists('cur', __METHOD__) || $this->db->tableExists('revision', __METHOD__);
 }
All Usage Examples Of Database::tableExists