}
/**
+ * Build appropriate INTERVAL clause for the database in use
+ *
+ * @param mixed $dbh
+ * @param string $interval
+ * @param string $precision
+ *
+ * @return string
+ */
+ public function buildIntervalClause($dbh, $interval, $precision)
+ {
+ $type = $dbh instanceof Horde_Db_Adapter ? Horde_String::lower($dbh->adapterName()) : $dbh->phptype;
+ var_dump($type);
+ switch ($type) {
+ case 'pgsql':
+ case 'pdo_postgresql':
+ $clause = 'INTERVAL \'' . $interval . ' ' . $precision . '\'';
+ break;
+ case 'oci8':
+ $clause = 'INTERVAL ' . $interval . '(' . $precision . ')';
+ break;
+ default:
+ $clause = 'INTERVAL ' . $interval . ' ' . $precision;
+ }
+
+ return $clause;
+ }
+
+ /**
* Escapes all characters in a string that are placeholders for the
* prepare/execute methods of the DB package.
*
$cols = $t->getColumns();
if (!in_array('event_allday', array_keys($cols))) {
$this->addColumn('kronolith_events', 'event_allday', 'integer', array('default' => 0));
- $this->_connection->execute('UPDATE kronolith_events SET event_allday = 1 WHERE event_start + INTERVAL 1 DAY = event_end');
+ $this->_connection->execute('UPDATE kronolith_events SET event_allday = 1 WHERE event_start + ' . Horde_SQL::buildIntervalClause($this->_connection, '1 DAY') . ' = event_end');
}
}