26 include_once XOOPS_ROOT_PATH .
'/class/logger/xoopslogger.php';
27 include_once XOOPS_ROOT_PATH .
'/class/database/databasefactory.php';
28 include_once XOOPS_ROOT_PATH .
'/class/database/' .
XOOPS_DB_TYPE .
'database.php';
29 include_once XOOPS_ROOT_PATH .
'/class/database/sqlutility.php';
54 return ($this->db->connect(
false) !=
false) ?
true :
false;
59 return ($this->db->connect() !=
false) ?
true :
false;
64 $this->db->connect(
false);
68 return (
$result !=
false) ?
true :
false;
75 if (!file_exists($sql_file_path)) {
78 $sql_query = trim(fread(fopen($sql_file_path,
'r'), filesize($sql_file_path)));
81 foreach ($pieces as $piece) {
82 $piece = trim($piece);
86 if ($prefixed_query !=
false ) {
87 $table = $this->db->prefix($prefixed_query[4]);
88 if ($prefixed_query[1] ==
'CREATE TABLE') {
89 if ($this->db->query($prefixed_query[0]) !=
false) {
90 if (!isset($this->s_tables[
'create'][$table])) {
91 $this->s_tables[
'create'][$table] = 1;
94 if (!isset($this->f_tables[
'create'][$table])) {
95 $this->f_tables[
'create'][$table] = 1;
98 }
else if ($prefixed_query[1] ==
'INSERT INTO') {
99 if ($this->db->query($prefixed_query[0]) !=
false) {
100 if (!isset($this->s_tables[
'insert'][$table])) {
101 $this->s_tables[
'insert'][$table] = 1;
103 $this->s_tables[
'insert'][$table]++;
106 if (!isset($this->f_tables[
'insert'][$table])) {
107 $this->f_tables[
'insert'][$table] = 1;
109 $this->f_tables[
'insert'][$table]++;
112 }
else if ($prefixed_query[1] ==
'ALTER TABLE') {
113 if ($this->db->query($prefixed_query[0]) !=
false) {
114 if (!isset($this->s_tables[
'alter'][$table])) {
115 $this->s_tables[
'alter'][$table] = 1;
118 if (!isset($this->s_tables[
'alter'][$table])) {
119 $this->f_tables[
'alter'][$table] = 1;
122 }
else if ($prefixed_query[1] ==
'DROP TABLE') {
123 if ($this->db->query(
'DROP TABLE '.$table) !=
false) {
124 if (!isset($this->s_tables[
'drop'][$table])) {
125 $this->s_tables[
'drop'][$table] = 1;
128 if (!isset($this->s_tables[
'drop'][$table])) {
129 $this->f_tables[
'drop'][$table] = 1;
154 $commands = array(
'create',
'insert',
'alter',
'drop' );
156 foreach ($commands as $cmd) {
157 if (!@empty($this->s_tables[$cmd])) {
158 foreach ($this->s_tables[$cmd] as $key => $val) {
160 $content .= ($cmd !=
'insert') ? sprintf($this->successStrings[$cmd], $key) : sprintf($this->successStrings[$cmd], $val, $key);
165 foreach ($commands as $cmd) {
166 if (!@empty( $this->f_tables[$cmd])) {
167 foreach ($this->f_tables[$cmd] as $key => $val) {
169 $content .= ($cmd !=
'insert') ? sprintf($this->failureStrings[$cmd], $key) : sprintf($this->failureStrings[$cmd], $val, $key);
180 $this->db->connect();
181 return $this->db->query(
$sql);
186 $this->db->connect();
187 return $this->db->prefix($table);
192 $this->db->connect();
193 return $this->db->fetchArray(
$ret);
198 $this->db->connect();
199 $table = $this->db->prefix($table);
201 if (!$this->db->queryF(
$query)) {
202 if (!isset($this->f_tables[
'insert'][$table])) {
203 $this->f_tables[
'insert'][$table] = 1;
205 $this->f_tables[
'insert'][$table]++;
209 if (!isset($this->s_tables[
'insert'][$table])) {
210 $this->s_tables[
'insert'][$table] = 1;
212 $this->s_tables[
'insert'][$table]++;
214 return $this->db->getInsertId();
220 return (isset($this->f_tables)) ?
true :
false;
226 $this->db->connect();
227 foreach (
$tables as $key => $val) {
228 if (!$this->db->query(
"DROP TABLE " . $this->db->prefix($key))) {
237 $table = trim($table);
240 $this->db->connect();
241 $sql =
'SELECT COUNT(*) FROM ' . $this->db->prefix($table);
242 $ret = (
false != $this->db->query(
$sql)) ?
true :
false;