/** * storeMetaData * * @param numeric $pAttachmentId AttachmentID the data belongs to * @param string $pType Type of data. e.g.: EXIF, ID3. This will default to "Meta Data" * @param array $pStoreHash Data that needs to be stored in the database in an array. The key will be used as the meta_title. * @access public * @return TRUE on success, FALSE on failure */ function storeMetaData($pAttachmentId, $pType = "Meta Data", $pStoreHash) { global $gBitSystem; $ret = FALSE; if (@BitBase::verifyId($pAttachmentId) && !empty($pType) && !empty($pStoreHash)) { if (is_array($pStoreHash)) { foreach ($pStoreHash as $key => $data) { if (!is_array($data)) { // store the data in the meta table $meta = array('attachment_id' => $pAttachmentId, 'meta_type_id' => LibertyMime::storeMetaId($pType, 'type'), 'meta_title_id' => LibertyMime::storeMetaId($key, 'title')); // remove this entry from the database if it already exists $gBitSystem->mDb->query("DELETE FROM `" . BIT_DB_PREFIX . "liberty_attachment_meta_data` WHERE `attachment_id` = ? AND `meta_type_id` = ? AND `meta_title_id` = ?", $meta); // don't insert empty lines if (!empty($data)) { $meta['meta_value'] = $data; $gBitSystem->mDb->associateInsert(BIT_DB_PREFIX . "liberty_attachment_meta_data", $meta); } $ret = TRUE; } else { // should we recurse? } } } } return $ret; }