/** * Fetches all object IDs, arranged by objectType, that belong to the given instance * * Array returned is of the form: * * array { * ['<objectType>'] => array { * [<objectID>] => true * } * } * * @param integer|string instance ID * @return Array */ public static function fetchObjectIdsByInstance($instanceID) { if (!isset(self::$attachmentTable)) { self::$attachmentTable = QFrame_Db_Table::getTable('attachment'); } $result = array(); // Get all files assocated with this instance ID $select = self::$attachmentTable->getAdapter()->select()->from(array('a' => 'attachment'), array('objectType', 'objectID'))->where('a.instanceID = ?', $instanceID); $stmt = self::$attachmentTable->getAdapter()->query($select); $rows = $stmt->fetchAll(); // Sort files by objectType and add them to the array to be returned foreach ($rows as $row) { $result[$row['objectType']][$row['objectID']] = true; } return $result; }