20 defined(
'XOOPS_ROOT_PATH') or die('Restricted access');
49 function cleanOrphan($table_link =
'', $field_link =
'', $field_object =
'')
51 if (!empty($table_link)) {
52 $this->handler->table_link = $table_link;
54 if (!empty($field_link)) {
55 $this->handler->field_link = $field_link;
57 if (!empty($field_object)) {
58 $this->handler->field_object = $field_object;
61 if (empty($this->handler->field_object) || empty($this->handler->table_link) || empty($this->handler->field_link)) {
62 trigger_error(
"The link information is not set for '" . get_class($this->handler) .
"' yet.", E_USER_WARNING);
69 if (version_compare(mysql_get_server_info(),
"4.1.0",
"ge")) {
70 $sql =
"DELETE FROM `{$this->handler->table}`"
71 .
" WHERE (`{$this->handler->field_object}` NOT IN ( SELECT DISTINCT `{$this->handler->field_link}` FROM `{$this->handler->table_link}`) )";
74 $sql =
"DELETE `{$this->handler->table}` FROM `{$this->handler->table}`"
75 .
" LEFT JOIN `{$this->handler->table_link}` AS aa ON `{$this->handler->table}`.`{$this->handler->field_object}` = aa.`{$this->handler->field_link}`"
76 .
" WHERE (aa.`{$this->handler->field_link}` IS NULL)";
90 function synchronization()
92 $retval = $this->cleanOrphan();