add method to check if ORMTable exists
authoraude <aude.wiki@gmail.com>
Tue, 4 Dec 2012 13:09:00 +0000 (13:09 +0000)
committeraude <aude.wiki@gmail.com>
Tue, 4 Dec 2012 13:09:51 +0000 (13:09 +0000)
Change-Id: I7ef34545a9b4cfa6ed8bcdd302ad49faa7747974

includes/db/IORMTable.php
includes/db/ORMTable.php

index be4036e..dfc5916 100644 (file)
@@ -229,6 +229,15 @@ interface IORMTable {
         */
        public function has( array $conditions = array() );
 
+       /**
+        * Checks if the table exists
+        *
+        * @since 1.21
+        *
+        * @return boolean
+        */
+       public function exists();
+
        /**
         * Returns the amount of matching records.
         * Condition field names get prefixed.
index a2ef944..e3c8aa7 100644 (file)
@@ -299,6 +299,21 @@ abstract class ORMTable extends DBAccessBase implements IORMTable {
                return $this->selectRow( array( 'id' ), $conditions ) !== false;
        }
 
+       /**
+        * Checks if the table exists
+        *
+        * @since 1.21
+        *
+        * @return boolean
+        */
+       public function exists() {
+               $dbr = $this->getReadDbConnection();
+               $exists = $dbr->tableExists( $this->getName() );
+               $this->releaseConnection( $dbr );
+
+               return $exists;
+       }
+
        /**
         * Returns the amount of matching records.
         * Condition field names get prefixed.