@@ 315-333 (lines=19) @@ | ||
312 | * @return bool true if success, false if an error occured |
|
313 | * |
|
314 | */ |
|
315 | public function alterTable() |
|
316 | { |
|
317 | global $xoopsDB; |
|
318 | ||
319 | $ret = true; |
|
320 | ||
321 | foreach ($this->getAlteredFields() as $alteredField) { |
|
322 | $query = sprintf('ALTER TABLE `%s` CHANGE `%s` %s', $this->name(), $alteredField['name'], $alteredField['properties']); |
|
323 | //echo $query; |
|
324 | $ret = $ret && $xoopsDB->query($query); |
|
325 | if (!$ret) { |
|
326 | echo "<li class='err'>" . sprintf(_AM_SPARTNER_DB_MSG_CHGFIELD_ERR, $alteredField['name'], $this->name()) . '</li>'; |
|
327 | } else { |
|
328 | echo "<li class='ok'>" . sprintf(_AM_SPARTNER_DB_MSG_CHGFIELD, $alteredField['name'], $this->name()) . '</li>'; |
|
329 | } |
|
330 | } |
|
331 | ||
332 | return $ret; |
|
333 | } |
|
334 | ||
335 | /** |
|
336 | * Use to add new fileds in the table |
|
@@ 341-357 (lines=17) @@ | ||
338 | * @return bool true if success, false if an error occured |
|
339 | * |
|
340 | */ |
|
341 | public function addNewFields() |
|
342 | { |
|
343 | global $xoopsDB; |
|
344 | $ret = true; |
|
345 | ||
346 | foreach ($this->getNewFields() as $newField) { |
|
347 | $query = sprintf('ALTER TABLE `%s` ADD `%s` %s', $this->name(), $newField['name'], $newField['properties']); |
|
348 | $ret = $ret && $xoopsDB->query($query); |
|
349 | if (!$ret) { |
|
350 | echo "<li class='err'>" . sprintf(_AM_SPARTNER_DB_MSG_NEWFIELD_ERR, $newField['name'], $this->name()) . '</li>'; |
|
351 | } else { |
|
352 | echo "<li class='ok'>" . sprintf(_AM_SPARTNER_DB_MSG_NEWFIELD, $newField['name'], $this->name()) . '</li>'; |
|
353 | } |
|
354 | } |
|
355 | ||
356 | return $ret; |
|
357 | } |
|
358 | ||
359 | /** |
|
360 | * Use to update fields values |
@@ 461-478 (lines=18) @@ | ||
458 | * @return bool true if success, false if an error occured |
|
459 | * |
|
460 | */ |
|
461 | public function addNewFields() |
|
462 | { |
|
463 | global $xoopsDB; |
|
464 | ||
465 | $ret = true; |
|
466 | foreach ($this->getNewFields() as $newField) { |
|
467 | $query = sprintf('ALTER TABLE `%s` ADD `%s` %s', $this->name(), $newField['name'], $newField['properties']); |
|
468 | //echo $query; |
|
469 | $ret = $ret && $xoopsDB->query($query); |
|
470 | if (!$ret) { |
|
471 | echo ' ' . sprintf(_SDU_MSG_NEWFIELD_ERR, $newField['name'], $this->name()) . '<br>'; |
|
472 | } else { |
|
473 | echo ' ' . sprintf(_SDU_MSG_NEWFIELD, $newField['name'], $this->name()) . '<br>'; |
|
474 | } |
|
475 | } |
|
476 | ||
477 | return $ret; |
|
478 | } |
|
479 | ||
480 | /** |
|
481 | * Use to update fields values |