$params = $objects;
$params[] = $type;
- $ids = $this->_db->selectAssoc('SELECT object_id, object_name FROM ' . $this->_t('objects') . ' WHERE object_name IN (' . str_repeat('?,', count($objects) - 1) . '?)' . ' AND type_id = ?', $params);
- if ($ids) {
- return $ids;
+ try {
+ $ids = $this->_db->selectAssoc('SELECT object_id, object_name FROM ' . $this->_t('objects') . ' WHERE object_name IN (' . str_repeat('?,', count($objects) - 1) . '?)' . ' AND type_id = ?', $params);
+ if ($ids) {
+ return $ids;
+ }
+ } catch (Horde_Db_Exception $e) {
+ throw new Content_Exception($e);
}
return false;
}
// Get the ids for any objects that already exist.
- if (count($objectName)) {
- foreach ($this->_db->selectAll('SELECT object_id, object_name FROM ' . $this->_t('objects')
- . ' WHERE object_name IN (' . implode(',', array_map(array($this->_db, 'quote'), array_keys($objectName)))
- . ') AND type_id = ' . $type) as $row) {
-
- $objectIndex = $objectName[$row['object_name']];
- unset($objectName[$row['object_name']]);
- $objectIds[$objectIndex] = $row['object_id'];
+ try {
+ if (count($objectName)) {
+ foreach ($this->_db->selectAll('SELECT object_id, object_name FROM ' . $this->_t('objects')
+ . ' WHERE object_name IN (' . implode(',', array_map(array($this->_db, 'quote'), array_keys($objectName)))
+ . ') AND type_id = ' . $type) as $row) {
+
+ $objectIndex = $objectName[$row['object_name']];
+ unset($objectName[$row['object_name']]);
+ $objectIds[$objectIndex] = $row['object_id'];
+ }
}
- }
- // Create any objects that didn't already exist
- foreach ($objectName as $object => $objectIndex) {
- $objectIds[$objectIndex] = $this->_db->insert('INSERT INTO ' . $this->_t('objects') . ' (object_name, type_id) VALUES (' . $this->_db->quote($object) . ', ' . $type . ')');
+ // Create any objects that didn't already exist
+ foreach ($objectName as $object => $objectIndex) {
+ $objectIds[$objectIndex] = $this->_db->insert('INSERT INTO ' . $this->_t('objects') . ' (object_name, type_id) VALUES (' . $this->_db->quote($object) . ', ' . $type . ')');
+ }
+ } catch (Horde_Db_Exception $e) {
+ throw new Content_Exception($e);
}
return $objectIds;
}
}
- // Get the ids for any types that already exist.
- if (count($typeName)) {
- foreach ($this->_db->selectAssoc('SELECT type_id, type_name FROM ' . $this->_t('types') . ' WHERE type_name IN ('.implode(',', array_map(array($this->_db, 'quote'), array_keys($typeName))).')') as $id => $type) {
- $typeIndex = $typeName[$type];
- unset($typeName[$type]);
- $typeIds[$typeIndex] = (int)$id;
+ try {
+ // Get the ids for any types that already exist.
+ if (count($typeName)) {
+ foreach ($this->_db->selectAssoc('SELECT type_id, type_name FROM ' . $this->_t('types') . ' WHERE type_name IN ('.implode(',', array_map(array($this->_db, 'quote'), array_keys($typeName))).')') as $id => $type) {
+ $typeIndex = $typeName[$type];
+ unset($typeName[$type]);
+ $typeIds[$typeIndex] = (int)$id;
+ }
}
- }
- // Create any types that didn't already exist
- foreach ($typeName as $type => $typeIndex) {
- $typeIds[$typeIndex] = $this->_db->insert('INSERT INTO ' . $this->_t('types') . ' (type_name) VALUES (' . $this->_db->quote($type) . ')');
+ // Create any types that didn't already exist
+ foreach ($typeName as $type => $typeIndex) {
+ $typeIds[$typeIndex] = $this->_db->insert('INSERT INTO ' . $this->_t('types') . ' (type_name) VALUES (' . $this->_db->quote($type) . ')');
+ }
+ } catch (Horde_Db_Exception $e) {
+ throw new Content_Exception($e);
}
return $typeIds;
}
// Get the ids for any users that already exist.
- if (count($userName)) {
- foreach ($this->_db->selectAll('SELECT user_id, user_name FROM ' . $this->_t('users') . ' WHERE user_name IN ('.implode(',', array_map(array($this->_db, 'quote'), array_keys($userName))).')') as $row) {
- $userIndex = $userName[$row['user_name']];
- unset($userName[$row['user_name']]);
- $userIds[$userIndex] = $row['user_id'];
+ try {
+ if (count($userName)) {
+ foreach ($this->_db->selectAll('SELECT user_id, user_name FROM ' . $this->_t('users') . ' WHERE user_name IN ('.implode(',', array_map(array($this->_db, 'quote'), array_keys($userName))).')') as $row) {
+ $userIndex = $userName[$row['user_name']];
+ unset($userName[$row['user_name']]);
+ $userIds[$userIndex] = $row['user_id'];
+ }
}
- }
- // Create any users that didn't already exist
- foreach ($userName as $user => $userIndex) {
- $userIds[$userIndex] = $this->_db->insert('INSERT INTO ' . $this->_t('users') . ' (user_name) VALUES (' . $this->_db->quote($user) . ')');
+ // Create any users that didn't already exist
+ foreach ($userName as $user => $userIndex) {
+ $userIds[$userIndex] = $this->_db->insert('INSERT INTO ' . $this->_t('users') . ' (user_name) VALUES (' . $this->_db->quote($user) . ')');
+ }
+ } catch (Horde_Db_Exception $e) {
+ throw new Content_Exception($e);
}
return $userIds;