/**
* Check for object existence without causing the objects to be created.
* Helps save queries for things like tags when we already know the object
* doesn't yet exist in rampage tables.
*
* @param mixed string|array $objects Either an object identifier or an
* array of them.
* @param mixed $type A type identifier. Either a string
* type name or the integer type_id.
*
* @return mixed Either a hash of object_id => object_names or false if
* the object(s) do not exist.
* @throws InvalidArgumentException, Content_Exception
*/
public function exists($objects, $type)
{
$type = current($this->_typeManager->ensureTypes($type));
if (!is_array($objects)) {
$objects = array($objects);
}
if (!count($objects)) {
return array();
}
// Ensure we take the object as a string indentifier.
foreach ($objects as &$object) {
$object = strval($object);
}
$params = $objects;
$params[] = $type;
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;
}