Code Duplication    Length = 18-24 lines in 2 locations

class/adodb.php 1 location

@@ 980-997 (lines=18) @@
977
	 * @param	string	$tbl
978
	 * @return	boolean
979
	 */
980
	public function TblExists ($tbl) {
981
		if ($this->IsDbSybase()) {
982
			$sql = "select count(1) as c from sysobjects where name = '$tbl' and type = 'U'";
983
			$rs = $this->Execute($sql);
984
			return (0 != $rs->fields['c']);
985
		}
986
		elseif ($this->IsDbMysql()) {
987
			$sql = "SHOW TABLES LIKE '$tbl'";
988
			$rs = $this->Execute($sql);
989
			return (0 != $rs->RowCount());
990
		}
991
		else {
992
			// :NOTICE: Un-tested method
993
			$sql = "select 1 from $tbl";
994
			$rs = $this->Execute($sql);
995
			return (0 == $this->ErrorNo());
996
		}
997
	} // end of func TblExists
998
999
1000
	/**

src/Fwlib/Bridge/Adodb.php 1 location

@@ 1161-1184 (lines=24) @@
1158
     * @param   string  $table
1159
     * @return  boolean
1160
     */
1161
    public function isTableExist($table)
1162
    {
1163
        $table = addslashes($table);
1164
1165
        // @codeCoverageIgnoreStart
1166
        if ($this->isDbSybase()) {
1167
            $sql = "SELECT count(1) AS c FROM sysobjects WHERE name =
1168
                '{$table}' AND type = 'U'";
1169
            $rs = $this->execute($sql);
1170
            return (0 != $rs->fields['c']);
1171
1172
        } elseif ($this->isDbMysql()) {
1173
            $sql = "SHOW TABLES LIKE '$table'";
1174
            $rs = $this->execute($sql);
1175
            return (0 != $rs->RowCount());
1176
1177
        } else {
1178
            // :THINK: Better method ?
1179
            $sql = "SELECT 1 FROM $table";
1180
            $this->execute($sql);
1181
            return (0 == $this->conn->ErrorNo());
1182
        }
1183
        // @codeCoverageIgnoreEnd
1184
    }
1185
1186
1187
    /**