function _insert($object) { $db = $this->getDb(); $sql = "INSERT INTO hordetest_turba_objects " . Horde_Sql::insertValues($db, $object) . ";"; $result = $db->query($sql); $this->assertOk($result); return $result; }
/** * Build a piece of an attribute query. * * @param string $glue The glue to join the criteria (OR/AND). * @param array $criteria The array of criteria. * @param boolean $join Should we join on a clean attributes table? * * @return string An SQL fragment. */ function _buildAttributeQuery($glue, $criteria, $join = false) { /* Initialize the clause that we're building. */ $clause = ''; /* Get the table alias to use for this set of criteria. */ if ($join) { $alias = $this->_getAlias(true); } else { $alias = $this->_getAlias(); } foreach ($criteria as $key => $vals) { if (!empty($vals['OR']) || !empty($vals['AND'])) { if (!empty($clause)) { $clause .= ' ' . $glue . ' '; } $clause .= '(' . $this->_buildAttributeQuery($glue, $vals) . ')'; } elseif (!empty($vals['JOIN'])) { if (!empty($clause)) { $clause .= ' ' . $glue . ' '; } $clause .= $this->_buildAttributeQuery($glue, $vals['JOIN'], true); } else { if (isset($vals['field'])) { if (!empty($clause)) { $clause .= ' ' . $glue . ' '; } $clause .= Horde_Sql::buildClause($this->_db, $alias . '.attribute_' . $vals['field'], $vals['op'], $vals['test']); } else { foreach ($vals as $test) { if (!empty($clause)) { $clause .= ' ' . $key . ' '; } $clause .= Horde_Sql::buildClause($this->_db, $alias . '.attribute_' . $test['field'], $test['op'], $test['test']); } } } } return $clause; }