Skip to content

Commit

Permalink
Don't hard code the owner_id field.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrubinsk committed Aug 18, 2015
1 parent e21ab41 commit 79e69a0
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions turba/lib/Driver/Sql.php
Expand Up @@ -503,9 +503,14 @@ protected function _deleteAll($sourceName = null)
? array($GLOBALS['registry']->getAuth())
: array($sourceName);

if (empty($this->_params['map']['__owner'])) {
throw new Turba_Exception(_("Unable to find __owner field. Cannot delete."));
}
$owner_field = $this->_params['map']['__owner'];

/* Need a list of UIDs so we can notify History */
$query = 'SELECT '. $this->map['__uid'] . ' FROM '
. $this->_params['table'] . ' WHERE owner_id = ?';
$query = sprintf('SELECT %s FROM %s WHERE %s = ?',
$this->map['__uid'], $this->_params['table'], $owner_field);

try {
$ids = $this->_db->selectValues($query, $values);
Expand All @@ -514,8 +519,7 @@ protected function _deleteAll($sourceName = null)
}

/* Do the deletion */
$query = 'DELETE FROM ' . $this->_params['table'] . ' WHERE owner_id = ?';

$query = sprintf('DELETE FROM %s WHERE %s = ?', $this->_params['table'], $owner_field);
try {
$this->_db->delete($query, $values);
} catch (Horde_Db_Exception $e) {
Expand Down

0 comments on commit 79e69a0

Please sign in to comment.