64 $this->successStrings = array(
70 $this->failureStrings = array(
85 return ($this->db->connect(
false) !=
false) ?
true :
false;
95 return ($this->db->connect() !=
false) ?
true :
false;
105 $this->db->connect(
false);
109 return (
$result !=
false) ?
true :
false;
125 $queryFunc = (bool)$force ?
"queryF" :
"query";
126 $sql_query = trim(fread(fopen($sql_file_path,
'r'), filesize($sql_file_path)));
128 $this->db->connect();
129 foreach ($pieces as $piece) {
130 $piece = trim($piece);
134 if ($prefixed_query !=
false) {
135 $table = $this->db->prefix($prefixed_query[4]);
136 if ($prefixed_query[1] ==
'CREATE TABLE') {
137 if ($this->db->$queryFunc($prefixed_query[0]) !=
false) {
138 if (!isset($this->s_tables[
'create'][$table])) {
139 $this->s_tables[
'create'][$table] = 1;
142 if (!isset($this->f_tables[
'create'][$table])) {
143 $this->f_tables[
'create'][$table] = 1;
147 if ($prefixed_query[1] ==
'INSERT INTO') {
148 if ($this->db->$queryFunc($prefixed_query[0]) !=
false) {
149 if (!isset($this->s_tables[
'insert'][$table])) {
150 $this->s_tables[
'insert'][$table] = 1;
152 $this->s_tables[
'insert'][$table]++;
155 if (!isset($this->f_tables[
'insert'][$table])) {
156 $this->f_tables[
'insert'][$table] = 1;
158 $this->f_tables[
'insert'][$table]++;
162 if ($prefixed_query[1] ==
'ALTER TABLE') {
163 if ($this->db->$queryFunc($prefixed_query[0]) !=
false) {
164 if (!isset($this->s_tables[
'alter'][$table])) {
165 $this->s_tables[
'alter'][$table] = 1;
168 if (!isset($this->s_tables[
'alter'][$table])) {
169 $this->f_tables[
'alter'][$table] = 1;
173 if ($prefixed_query[1] ==
'DROP TABLE') {
174 if ($this->db->$queryFunc(
'DROP TABLE ' . $table) !=
false) {
175 if (!isset($this->s_tables[
'drop'][$table])) {
176 $this->s_tables[
'drop'][$table] = 1;
179 if (!isset($this->s_tables[
'drop'][$table])) {
180 $this->f_tables[
'drop'][$table] = 1;
199 $commands = array(
'create',
'insert',
'alter',
'drop');
201 foreach ($commands as $cmd) {
202 if (!@empty($this->s_tables[$cmd])) {
203 foreach ($this->s_tables[$cmd] as $key => $val) {
206 ? sprintf($this->successStrings[$cmd], $key)
207 : sprintf($this->successStrings[$cmd], $val, $key);
212 foreach ($commands as $cmd) {
213 if (!@empty($this->f_tables[$cmd])) {
214 foreach ($this->f_tables[$cmd] as $key => $val) {
217 ? sprintf($this->failureStrings[$cmd], $key)
218 : sprintf($this->failureStrings[$cmd], $val, $key);
236 $this->db->connect();
237 return $this->db->query(
$sql);
249 $this->db->connect();
250 return $this->db->prefix($table);
262 $this->db->connect();
263 return $this->db->fetchArray($ret);
276 $this->db->connect();
277 $table = $this->db->prefix($table);
279 if (!$this->db->queryF(
$query)) {
280 if (!isset($this->f_tables[
'insert'][$table])) {
281 $this->f_tables[
'insert'][$table] = 1;
283 $this->f_tables[
'insert'][$table]++;
287 if (!isset($this->s_tables[
'insert'][$table])) {
288 $this->s_tables[
'insert'][$table] = 1;
290 $this->s_tables[
'insert'][$table]++;
292 return $this->db->getInsertId();
303 return (isset($this->f_tables)) ?
true :
false;
319 $this->db->connect();
320 foreach ($tables as $key => $val) {
322 if (!$this->db->query(
"DROP TABLE " . $this->db->prefix($val))) {
338 $table = trim($table);
341 $this->db->connect();
342 $sql =
'SELECT COUNT(*) FROM ' . $this->db->prefix($table);
343 $ret = (
false != $this->db->query(
$sql)) ?
true :
false;
365 $sql =
"SHOW COLUMNS FROM " . $this->db->prefix($oTableName);
367 if (($rows = $this->db->getRowsNum(
$result)) == count($fieldsMap)) {
368 $sql =
"SELECT * FROM " . $this->db->prefix($oTableName);
370 while ($myrow = $this->db->fetchArray(
$result)) {
373 $sql =
"INSERT INTO `" . $this->db->prefix($nTableName)
374 .
"` " .
"(`" . implode(
"`,`", $fieldsMap) .
"`)" .
375 " VALUES ('" . implode(
"','", $myrow) .
"')";
377 $this->db->queryF(
$sql);
380 $sql =
"DROP TABLE " . $this->db->prefix($oTableName);
381 $this->db->queryF(
$sql);
static prefixQuery($query, $prefix)
static splitMySqlFile(&$ret, $sql)
const EF_TABLE_NOT_CREATED
queryFromFile($sql_file_path, $force=false)
copyFields($fieldsMap, $oTableName, $nTableName, $dropTable=false)
const EF_ENTRIES_NOT_INSERTED_TO_TABLE
const EF_TABLE_NOT_UPDATED
const SF_ENTRIES_INSERTED_TO_TABLE
const EF_TABLE_NOT_DROPPED