XOOPS 2.5.6  Final
 All Classes Namespaces Files Functions Variables Pages
sync.php
Go to the documentation of this file.
1 <?php
20 defined('XOOPS_ROOT_PATH') or die('Restricted access');
21 
40 {
49  function cleanOrphan($table_link = '', $field_link = '', $field_object = '')
50  {
51  if (!empty($table_link)) {
52  $this->handler->table_link = $table_link;
53  }
54  if (!empty($field_link)) {
55  $this->handler->field_link = $field_link;
56  }
57  if (!empty($field_object)) {
58  $this->handler->field_object = $field_object;
59  }
60 
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);
63  return null;
64  }
65 
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}`) )";
72  } else {
73  // for 4.0+
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)";
77  }
78  if (!$result = $this->handler->db->queryF($sql)) {
79  return false;
80  }
81  return true;
82  }
83 
90  function synchronization()
91  {
92  $retval = $this->cleanOrphan();
93  return $retval;
94  }
95 }
96 
97 ?>