| @@ 96-113 (lines=18) @@ | ||
| 93 | * the name of the table to use |
|
| 94 | * @return void |
|
| 95 | */ |
|
| 96 | public function removeTable($tableName) |
|
| 97 | { |
|
| 98 | // what are we doing? |
|
| 99 | $log = Log::usingLog()->startAction("remove table '{$tableName}' from the runtime tables"); |
|
| 100 | ||
| 101 | // does the table exist? |
|
| 102 | if (!RuntimeTable::fromRuntimeTables()->getTableExists($tableName)) { |
|
| 103 | $log->endAction(); |
|
| 104 | return; |
|
| 105 | } |
|
| 106 | ||
| 107 | // get the tables |
|
| 108 | $tables = RuntimeTable::fromRuntimeTables()->getAllTablesSilently(); |
|
| 109 | unset($tables->$tableName); |
|
| 110 | ||
| 111 | // all done |
|
| 112 | $log->endAction("table '{$tableName}' removed"); |
|
| 113 | } |
|
| 114 | ||
| 115 | /** |
|
| 116 | * remove a table if, and only if, it is empty |
|
| @@ 122-139 (lines=18) @@ | ||
| 119 | * the name of the table to remove |
|
| 120 | * @return void |
|
| 121 | */ |
|
| 122 | public function removeTableIfEmpty($tableName) |
|
| 123 | { |
|
| 124 | // what are we doing? |
|
| 125 | $log = Log::usingLog()->startAction("remove table '{$tableName}' from the runtime tables if it is empty"); |
|
| 126 | ||
| 127 | // is the table empty? |
|
| 128 | if (!RuntimeTable::fromRuntimeTable($tableName)->getIsEmpty()) { |
|
| 129 | $log->endAction("not removing; table is not empty"); |
|
| 130 | return; |
|
| 131 | } |
|
| 132 | ||
| 133 | // if we get here, the table is empty |
|
| 134 | $tables = RuntimeTable::fromRuntimeTables()->getAllTablesSilently(); |
|
| 135 | unset($tables->$tableName); |
|
| 136 | ||
| 137 | // all done |
|
| 138 | $log->endAction("table '{$tableName}' removed; table was empty"); |
|
| 139 | } |
|
| 140 | } |
|
| 141 | ||