| @@ 981-998 (lines=18) @@ | ||
| 978 | * @param string $tbl |
|
| 979 | * @return boolean |
|
| 980 | */ |
|
| 981 | public function TblExists ($tbl) { |
|
| 982 | if ($this->IsDbSybase()) { |
|
| 983 | $sql = "select count(1) as c from sysobjects where name = '$tbl' and type = 'U'"; |
|
| 984 | $rs = $this->Execute($sql); |
|
| 985 | return (0 != $rs->fields['c']); |
|
| 986 | } |
|
| 987 | elseif ($this->IsDbMysql()) { |
|
| 988 | $sql = "SHOW TABLES LIKE '$tbl'"; |
|
| 989 | $rs = $this->Execute($sql); |
|
| 990 | return (0 != $rs->RowCount()); |
|
| 991 | } |
|
| 992 | else { |
|
| 993 | // :NOTICE: Un-tested method |
|
| 994 | $sql = "select 1 from $tbl"; |
|
| 995 | $rs = $this->Execute($sql); |
|
| 996 | return (0 == $this->ErrorNo()); |
|
| 997 | } |
|
| 998 | } // end of func TblExists |
|
| 999 | ||
| 1000 | ||
| 1001 | /** |
|
| @@ 1190-1213 (lines=24) @@ | ||
| 1187 | * @param string $table |
|
| 1188 | * @return boolean |
|
| 1189 | */ |
|
| 1190 | public function isTableExist($table) |
|
| 1191 | { |
|
| 1192 | $table = addslashes($table); |
|
| 1193 | ||
| 1194 | // @codeCoverageIgnoreStart |
|
| 1195 | if ($this->isDbSybase()) { |
|
| 1196 | $sql = "SELECT count(1) AS c FROM sysobjects WHERE name = |
|
| 1197 | '{$table}' AND type = 'U'"; |
|
| 1198 | $rs = $this->execute($sql); |
|
| 1199 | ||
| 1200 | return (0 != $rs->fields['c']); |
|
| 1201 | ||
| 1202 | } elseif ($this->isDbMysql()) { |
|
| 1203 | $sql = "SHOW TABLES LIKE '$table'"; |
|
| 1204 | $rs = $this->execute($sql); |
|
| 1205 | ||
| 1206 | return (0 != $rs->RowCount()); |
|
| 1207 | ||
| 1208 | } else { |
|
| 1209 | // :THINK: Better method ? |
|
| 1210 | $sql = "SELECT 1 FROM $table"; |
|
| 1211 | $this->execute($sql); |
|
| 1212 | ||
| 1213 | return (0 == $this->conn->ErrorNo()); |
|
| 1214 | } |
|
| 1215 | // @codeCoverageIgnoreEnd |
|
| 1216 | } |
|