51 if (empty($this->handler->table_link) || empty($this->handler->field_link)) {
52 trigger_error(
"The linked table is not set yet.", E_USER_WARNING);
55 if (empty($this->handler->field_object)) {
56 $this->handler->field_object = $this->handler->field_link;
79 if (!empty($field_link)) {
80 $this->handler->field_link = $field_link;
82 if (!empty($field_object)) {
83 $this->handler->field_object = $field_object;
89 $qb = $this->handler->db2->createXoopsQueryBuilder();
90 if (is_array($fields) && count($fields)) {
91 if (!in_array(
"o." . $this->handler->keyName, $fields)) {
92 $fields[] =
"o." . $this->handler->keyName;
95 foreach ($fields as $field) {
100 $qb->addSelect($field);
107 $qb ->from($this->handler->table,
'o')
110 $this->handler->table_link,
112 "o.{$this->handler->field_object} = l.{$this->handler->field_link}"
120 while ($myrow =
$result->fetch(\PDO::FETCH_ASSOC)) {
121 $object = $this->handler->create(
false);
122 $object->assignVars($myrow);
123 $ret[$myrow[$this->handler->keyName]] = $object;
127 $object = $this->handler->create(
false);
128 while ($myrow =
$result->fetch(\PDO::FETCH_ASSOC)) {
129 $object->assignVars($myrow);
130 $ret[$myrow[$this->handler->keyName]] = $object->getValues();
150 $qb = $this->handler->db2->createXoopsQueryBuilder();
152 $qb ->select(
"COUNT(DISTINCT o.{$this->handler->keyName})")
153 ->from($this->handler->table,
'o')
156 $this->handler->table_link,
158 "o.{$this->handler->field_object} = l.{$this->handler->field_link}"
166 return $result->fetchColumn(0);
183 $qb = $this->handler->db2->createXoopsQueryBuilder();
185 $qb ->select(
"l.{$this->handler->keyName_link}")
186 ->addSelect(
'COUNT(*)')
187 ->from($this->handler->table,
'o')
190 $this->handler->table_link,
192 "o.{$this->handler->field_object} = l.{$this->handler->field_link}"
199 $qb ->groupBy(
"l.{$this->handler->keyName_link}");
231 foreach ($data as $key => $val) {
232 $set[] =
"o.{$key}=" . $this->handler->db2->quote($val);
234 $sql =
" UPDATE {$this->handler->table} AS o" .
" SET " . implode(
", ", $set)
235 .
" LEFT JOIN {$this->handler->table_link} AS l "
236 .
"ON o.{$this->handler->field_object} = l.{$this->handler->field_link}";
241 return $this->handler->db2->executeUpdate(
$sql);
263 $sql =
"DELETE FROM {$this->handler->table} AS o "
264 .
"LEFT JOIN {$this->handler->table_link} AS l "
265 .
"ON o.{$this->handler->field_object} = l.{$this->handler->field_link}";
270 return $this->handler->db2->executeUpdate(
$sql);
updateByLink(array $data, CriteriaElement $criteria=null)
getCountByLink(CriteriaElement $criteria=null)
deleteByLink(CriteriaElement $criteria=null)
getByLink(CriteriaElement $criteria=null, $fields=null, $asObject=true, $field_link=null, $field_object=null)
getCountsByLink(CriteriaElement $criteria=null)