/**
  * Deletes the data row from the appropriate table.
  * @param integer $dbID The {@link DBHandler} database ID to query.
  * @param integer $dataID The ID in the database of the data to be deleted.
  * @access public
  * @return void
  */
 function prune($dbID, $dataID)
 {
     if (!$dataID) {
         return;
     }
     // delete ourselves from our data table
     $table = $this->_table;
     $query = new DeleteQuery();
     $query->setTable($table);
     $query->setWhere("id='" . addslashes($dataID) . "'");
     $dbHandler = Services::getService("DatabaseManager");
     $res = $dbHandler->query($query, $dbID);
     if (!$res) {
         throwError(new UnknownDBError("StorablePrimitive"));
     }
 }
 /**
  * Deletes the components for the property from the db
  *
  * @param object StyleProperty $sp
  * @return void
  * @access public
  * @since 4/26/06
  */
 function deleteComponentsForProperty($sp)
 {
     $dbHandler = Services::getService("DatabaseManager");
     $id = $sp->getId();
     $idValue = $id->getIdString();
     $query = new DeleteQuery();
     $query->setTable($this->_dbName . ".tm_style_component");
     $query->addWhere("fk_property_id = {$idValue}");
     $result = $dbHandler->query($query, $this->_dbIndex);
 }
Beispiel #3
0
 /**
  * Add a new image at the path specified.
  * 
  * @param object Harmoni_Filing_FileInterface $image
  * @param string $filename
  * @param string $prefixPath
  * @return null
  * @access public
  * @since 5/15/08
  */
 public function addImage(Harmoni_Filing_FileInterface $image, $filename, $prefixPath = '')
 {
     if (!$this->canModify()) {
         throw new PermissionDeniedException();
     }
     ArgumentValidator::validate($filename, NonzeroLengthStringValidatorRule::getRule());
     $path = trim($prefixPath, '/');
     if (strlen($path)) {
         $path = $path . '/' . $filename;
     } else {
         $path = $filename;
     }
     // Delete the old image
     $query = new DeleteQuery();
     $query->setTable('segue_site_theme_image');
     $query->addWhereEqual('fk_theme', $this->id);
     $query->addWhereEqual('path', $path);
     $dbc = Services::getService('DatabaseManager');
     $dbc->query($query, $this->databaseIndex);
     $query = new InsertQuery();
     $query->setTable('segue_site_theme_image');
     $query->addValue('fk_theme', $this->id);
     $query->addValue('mime_type', $image->getMimeType());
     $query->addValue('path', $path);
     $query->addValue('size', $image->getSize());
     $query->addValue('data', base64_encode($image->getContents()));
     $dbc = Services::getService('DatabaseManager');
     $dbc->query($query, $this->databaseIndex);
 }
Beispiel #4
0
 /**
  * Delete the file.
  * 
  * @return null
  * @access public
  * @since 5/15/08
  */
 public function delete()
 {
     $query = new DeleteQuery();
     $query->setTable('segue_site_theme_image');
     $query->addWhereEqual('fk_theme', $this->themeId);
     $query->addWhereEqual('path', $this->path);
     $dbMgr = Services::getService("DatabaseManager");
     $dbMgr->query($query, $this->databaseIndex);
 }
 /**
  * Delete the item and all tags for it. This should be done when deleting
  * the thing the item represents
  * 
  * @param mixed $items This can be a single Item object, an TaggedItemIterator, 
  * 		or an array of Item objects.
  * @return void
  * @access public
  * @since 11/2/06
  */
 function deleteItems($items)
 {
     $itemDbIds = array();
     // array
     if (is_array($items)) {
         foreach (array_keys($items) as $key) {
             $itemDbIds[] = "'" . addslashes($items[$key]->getDatabaseId()) . "'";
         }
     } else {
         if (method_exists($items, 'next')) {
             while ($items->hasNext()) {
                 $item = $items->next();
                 $itemDbIds[] = "'" . addslashes($item->getDatabaseId()) . "'";
             }
         } else {
             if (method_exists($items, 'getDatabaseId')) {
                 $itemDbIds[] = "'" . addslashes($items->getDatabaseId()) . "'";
             } else {
                 throwError(new Error("Invalid parameter, {$items}, for \$items", "Tagging"));
             }
         }
     }
     if (!count($itemDbIds)) {
         return;
     }
     $dbc = Services::getService("DatabaseManager");
     $query = new DeleteQuery();
     $query->setTable('tag');
     $query->addWhere("tag.fk_item IN (" . implode(", ", $itemDbIds) . ")");
     $dbc->query($query, $this->getDatabaseIndex());
     $query = new DeleteQuery();
     $query->setTable('tag_item');
     $query->addWhere("id IN (" . implode(", ", $itemDbIds) . ")");
     $dbc->query($query, $this->getDatabaseIndex());
 }
 /**
  * Delete the DMRecord Set and any records that are referenced only by this record
  * set and not shared with other record sets.
  * 
  * @param int $id The Id of the set to delete.
  * @param optional boolean $prune If TRUE will make sure that the Records are removed
  * from the database.
  * @return void
  * @access public
  * @since 10/6/04
  */
 function deleteRecordSet($id, $prune = false)
 {
     ArgumentValidator::validate($id, StringValidatorRule::getRule());
     $recordSet = $this->fetchRecordSet($id);
     $recordSet->loadRecords($prune ? RECORD_FULL : RECORD_NODATA);
     // Delete the records in the set.
     $records = $recordSet->getRecords();
     foreach (array_keys($records) as $key) {
         $record = $records[$key];
         // Only delete records if they are not shared with other sets.
         $setsContaining = $this->getRecordSetIDsContaining($record);
         if (count($setsContaining) == 1 && $setsContaing[0] == $id) {
             $this->deleteRecord($record->getID(), $prune);
         }
     }
     // Delete the set from the database
     $query = new DeleteQuery();
     $query->setTable("dm_record_set");
     $query->addWhere("id = '" . addslashes($id) . "'");
     $dbHandler = Services::getService("DatabaseManager");
     $result = $dbHandler->query($query, DATAMANAGER_DBID);
     $this->_recordSetCache[$id] = NULL;
     unset($this->_recordSetCache[$id]);
 }
Beispiel #7
0
 /**
  * Save an XML string to the feed cache
  * 
  * @param string $url
  * @param string $feedXml
  * @return void
  * @access protected
  * @since 7/8/08
  */
 protected function cacheXmlString($url, $feedXml)
 {
     $dbc = Services::getService("DatabaseManager");
     $query = new DeleteQuery();
     $query->setTable('segue_plugins_rssfeed_cache');
     $query->addWhereEqual('url', $url);
     $query->addWhereRawLessThan('cache_time', $dbc->toDBDate(DateAndTime::now()->minus(Duration::withSeconds(600)), IMPORTER_CONNECTION), _OR);
     try {
         $result = $dbc->query($query, IMPORTER_CONNECTION);
     } catch (NoSuchTableDatabaseException $e) {
         $this->createCacheTable();
     }
     $query = new InsertQuery();
     $query->setTable('segue_plugins_rssfeed_cache');
     $query->addValue('url', $url);
     $query->addValue('feed_data', $feedXml);
     $dbc->query($query, IMPORTER_CONNECTION);
 }
 /**
  * Delete a Record.  If the specified Record has content that is inherited
  * by other Records, those other Records will not be deleted, but they
  * will no longer have a source from which to inherit value changes.
  * 
  * @param object Id $recordId
  * 
  * @throws object RepositoryException An exception with one of
  *         the following messages defined in
  *         org.osid.repository.RepositoryException may be thrown: {@link
  *         org.osid.repository.RepositoryException#OPERATION_FAILED
  *         OPERATION_FAILED}, {@link
  *         org.osid.repository.RepositoryException#PERMISSION_DENIED
  *         PERMISSION_DENIED}, {@link
  *         org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  *         CONFIGURATION_ERROR}, {@link
  *         org.osid.repository.RepositoryException#UNIMPLEMENTED
  *         UNIMPLEMENTED}, {@link
  *         org.osid.repository.RepositoryException#NULL_ARGUMENT
  *         NULL_ARGUMENT}, {@link
  *         org.osid.repository.RepositoryException#UNKNOWN_ID UNKNOWN_ID}
  * 
  * @access public
  */
 function deleteRecord(Id $recordId)
 {
     $record = $this->getRecord($recordId);
     $structure = $record->getRecordStructure();
     $structureId = $structure->getId();
     // If this is a schema that is hard coded into our implementation, create
     // a record for that schema.
     if (in_array($structureId->getIdString(), array_keys($this->_repository->_builtInTypes))) {
         // Delete all of the Parts for the record
         $parts = $record->getParts();
         while ($parts->hasNext()) {
             $part = $parts->next();
             $record->deletePart($part->getId());
         }
         // Delete the relation for the record.
         $dbHandler = Services::getService("DatabaseManager");
         $query = new DeleteQuery();
         $query->setTable("dr_asset_record");
         $myId = $this->getId();
         $query->addWhere("fk_asset = '" . $myId->getIdString() . "'");
         $query->addWhere("fk_record = '" . $recordId->getIdString() . "'");
         $result = $dbHandler->query($query, $this->_dbIndex);
     } else {
         $recordMgr = Services::getService("RecordManager");
         $record = $recordMgr->fetchRecord($recordId->getIdString(), RECORD_FULL);
         // Check if the record is part of other record sets (assets via inheretance)
         $myId = $this->getId();
         $setsContaining = $recordMgr->getRecordSetIDsContaining($record);
         $myRecordSet = $recordMgr->fetchRecordSet($myId->getIdString());
         // If this is the last asset referencing this record, delete it.
         $idManager = Services::getService('Id');
         if (count($setsContaining) == 1 && $myId->isEqual($idManager->getId($setsContaining[0]))) {
             $myRecordSet->removeRecord($record);
             $myRecordSet->commit(TRUE);
             $record->delete();
             $record->commit(TRUE);
         } else {
             $myRecordSet = $recordMgr->fetchRecordSet($myId->getIdString());
             $myRecordSet->removeRecord($record);
             $myRecordSet->commit(TRUE);
         }
     }
     $this->updateModificationDate();
 }
 /**
  * Commits any changes that have been made to the database. If neither update() nor prune() have been
  * called, even if changes have been made, they will not be reflected in the database.
  * @return bool
  * @access public
  */
 function commit()
 {
     $dbHandler = Services::getService("DatabaseManager");
     if ($this->_update) {
         // let's re-cast our primitive to a storablePrimitive
         $this->recastAsStorable();
         // first we need to commit the actual Primitive value
         // so that we can get its ID
         if (!$this->_dataID) {
             $this->_dataID = $this->_primitive->insert(DATAMANAGER_DBID);
         } else {
             $this->_primitive->update(DATAMANAGER_DBID, $this->_dataID);
         }
         $this->_date = DateAndTime::now();
         if ($this->_myID) {
             // we're already in the DB. just update the entry
             $query = new UpdateQuery();
             $query->setWhere("id='" . addslashes($this->_myID) . "'");
             $query->setColumns(array("value_index", "active", "modified"));
             $query->setValues(array($this->_parent->getIndex(), $this->_active ? 1 : 0, $dbHandler->toDBDate($this->_date, DATAMANAGER_DBID)));
         } else {
             // we have to insert a new one
             $query = new InsertQuery();
             $idManager = Services::getService("Id");
             $newID = $idManager->createId();
             $this->_myID = $newID->getIdString();
             $query->setColumns(array("id", "fk_record", "fk_schema_field", "value_index", "fk_data", "active", "modified"));
             $schema = $this->_parent->_parent->_parent->getSchema();
             $schemaField = $this->_parent->_parent->getSchemaField();
             $query->addRowOfValues(array("'" . addslashes($this->_myID) . "'", "'" . addslashes($this->_parent->_parent->_parent->getID()) . "'", "'" . addslashes($schemaField->getID()) . "'", $this->_parent->getIndex(), "'" . addslashes($this->_dataID) . "'", $this->_active ? 1 : 0, $dbHandler->toDBDate($this->_date, DATAMANAGER_DBID)));
         }
         $query->setTable("dm_record_field");
         $result = $dbHandler->query($query, DATAMANAGER_DBID);
         if (!$result) {
             throwError(new UnknownDBError("DMRecord"));
             return false;
         }
     }
     if ($this->_prune && $this->_dataID) {
         if ($id = $this->getID()) {
             // ok, let's get rid of ourselves... completely!
             $query = new DeleteQuery();
             $query->setTable("dm_record_field");
             $query->setWhere("id='" . addslashes($id) . "'");
             $res = $dbHandler->query($query, DATAMANAGER_DBID);
             if (!$res) {
                 throwError(new UnknownDBError("DMRecord"));
             }
             // now tell the data object to prune itself
             $this->recastAsStorable();
             $this->_primitive->prune(DATAMANAGER_DBID, $this->_dataID);
             // and we have to get rid of any tag mappings where we are included.
             $query = new DeleteQuery();
             $query->setTable("dm_tag_map");
             $query->setWhere("fk_record_field='" . addslashes($id) . "'");
             $res = $dbHandler->query($query, DATAMANAGER_DBID);
             if (!$res) {
                 throwError(new UnknownDBError("DMRecord"));
             }
         }
     }
     // reset the prune flag
     $this->_prune = false;
     // reset the update flag
     $this->_update = false;
     return true;
 }
 /**
  * Delete a Hierarchy by unique Id. All Nodes must be removed from the
  * Hierarchy before this method is called.
  * 
  * @param object Id $hierarchyId
  * 
  * @throws object HierarchyException An exception with one of
  *		   the following messages defined in
  *		   org.osid.hierarchy.HierarchyException may be thrown:	 {@link
  *		   org.osid.hierarchy.HierarchyException#OPERATION_FAILED
  *		   OPERATION_FAILED}, {@link
  *		   org.osid.hierarchy.HierarchyException#PERMISSION_DENIED
  *		   PERMISSION_DENIED}, {@link
  *		   org.osid.hierarchy.HierarchyException#CONFIGURATION_ERROR
  *		   CONFIGURATION_ERROR}, {@link
  *		   org.osid.hierarchy.HierarchyException#UNIMPLEMENTED
  *		   UNIMPLEMENTED}, {@link
  *		   org.osid.hierarchy.HierarchyException#NULL_ARGUMENT
  *		   NULL_ARGUMENT}, {@link
  *		   org.osid.hierarchy.HierarchyException#NODE_TYPE_NOT_FOUND
  *		   NODE_TYPE_NOT_FOUND}, {@link
  *		   org.osid.hierarchy.HierarchyException#HIERARCHY_NOT_EMPTY
  *		   HIERARCHY_NOT_EMPTY}
  * 
  * @access public
  */
 function deleteHierarchy(Id $hierarchyId)
 {
     // ** parameter validation
     ArgumentValidator::validate($hierarchyId, ExtendsValidatorRule::getRule("Id"), true);
     // ** end of parameter validation
     $dbHandler = Services::getService("DatabaseManager");
     $idValue = $hierarchyId->getIdString();
     // see if there are any nodes remaining that have to removed
     $query = new SelectQuery();
     $query->addTable("az2_node");
     $query->addColumn("COUNT(az2_node.id)", "num");
     $query->addWhereEqual("fk_hierarchy", $idValue);
     $queryResult = $dbHandler->query($query, $this->_dbIndex);
     $row = $queryResult->getCurrentRow();
     $queryResult->free();
     // if the hierarchy contains any nodes, cannot delete
     if ($row['num'] > 0) {
         throw new OperationFailedException("Hierarchy not empty.");
         return;
     }
     // now delete it
     $query = new DeleteQuery();
     $query->setTable("az2_hierarchy");
     $query->addWhereEqual("id", $idValue);
     $queryResult = $dbHandler->query($query, $this->_dbIndex);
     if ($queryResult->getNumberOfRows() != 1) {
         throw new OperationFailedException("Wrong number of rows deleted. Expecting 1.");
     }
     // update the cache
     $this->_hierarchies[$idValue] = null;
     unset($this->_hierarchies[$idValue]);
 }
 /**
  * Attempts to commit our {@link DMRecord}s to the database and update our mapping.
  * @param boolean optional $ignoreMandatory If true, doesn't fail if mandatory
  *		fields don't have values.
  * @return void
  */
 function commit($ignoreMandatory = false)
 {
     $ids = array();
     if (count($this->_records)) {
         for ($i = 0; $i < count($this->_records); $i++) {
             $this->_records[$i]->commit($ignoreMandatory);
             $ids[] = $this->_records[$i]->getID();
         }
         $this->_records = array();
         $this->_fetchMode = -1;
     }
     if ($this->_dirty) {
         // syncrhonize the database
         $ids = array_merge($ids, $this->_storedRecordIDs);
         // Make sure that we only have one ID for each record.
         $ids = array_unique($ids);
         $dbHandler = Services::getService("DatabaseManager");
         // first delete all the old mappings
         $query = new DeleteQuery();
         $query->setTable("dm_record_set");
         $query->setWhere("dm_record_set.id='" . addslashes($this->_myID) . "'");
         //			printpre(MySQL_SQLGenerator::generateSQLQuery($query));
         $dbHandler->query($query, DATAMANAGER_DBID);
         if (count($ids)) {
             // next insert all our mappings back in.
             $query = new InsertQuery();
             $query->setTable("dm_record_set");
             $query->setColumns(array("id", "fk_record"));
             foreach ($ids as $id) {
                 $query->addRowOfValues(array("'" . addslashes($this->_myID) . "'", "'" . addslashes($id) . "'"));
                 if (!in_array($id, $this->_storedRecordIDs)) {
                     $this->_storedRecordIDs[] = $id;
                 }
             }
             //				printpre(MySQL_SQLGenerator::generateSQLQuery($query));
             $dbHandler->query($query, DATAMANAGER_DBID);
             // done!
         }
     }
 }
Beispiel #12
0
 /**
  * Delete a slot
  * 
  * @param string $shortname
  * @return void
  * @access public
  * @since 12/5/07
  */
 public function deleteSlot($shortname)
 {
     $slot = $this->getSlotByShortname($shortname);
     if ($slot->siteExists()) {
         throw new PermissionDeniedException("Cannot delete a slot for an existing site.");
     }
     $query = new DeleteQuery();
     $query->setTable('segue_slot');
     $query->addWhereEqual('shortname', $shortname);
     $dbc = Services::getService('DBHandler');
     $result = $dbc->query($query, IMPORTER_CONNECTION);
     $query = new DeleteQuery();
     $query->setTable('segue_slot_owner');
     $query->addWhereEqual('shortname', $shortname);
     $dbc = Services::getService('DBHandler');
     $result = $dbc->query($query, IMPORTER_CONNECTION);
     unset($this->slots[$shortname]);
 }
 /**
  * Delete a Part and all its Parts.
  * 
  * @param object Id $partId
  * 
  * @throws object RepositoryException An exception with one of
  *		   the following messages defined in
  *		   org.osid.repository.RepositoryException may be thrown: {@link
  *		   org.osid.repository.RepositoryException#OPERATION_FAILED
  *		   OPERATION_FAILED}, {@link
  *		   org.osid.repository.RepositoryException#PERMISSION_DENIED
  *		   PERMISSION_DENIED}, {@link
  *		   org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  *		   CONFIGURATION_ERROR}, {@link
  *		   org.osid.repository.RepositoryException#UNIMPLEMENTED
  *		   UNIMPLEMENTED}, {@link
  *		   org.osid.repository.RepositoryException#NULL_ARGUMENT
  *		   NULL_ARGUMENT}, {@link
  *		   org.osid.repository.RepositoryException#UNKNOWN_ID UNKNOWN_ID}
  * 
  * @access public
  */
 function deletePart(Id $partId)
 {
     $string = $partId->getIdString();
     if (preg_match("/(.*)-(FILE_SIZE|FILE_NAME|FILE_DATA|MIME_TYPE|THUMBNAIL_DATA|THUMBNAIL_MIME_TYPE)/", $string, $r)) {
         $recordId = $r[1];
         $field = $r[2];
         if ($this->_isLastPart($field)) {
             $dbHandler = Services::getService("DatabaseManager");
             // Delete the data
             $file = $this->_parts['FILE_DATA']->_getFilePath();
             if (!unlink($file)) {
                 throwError(new Error(RepositoryException::OPERATION_FAILED() . ": '{$file}' could not be deleted.", "FileSystemFileRecord", true));
             }
             // Delete the thumbnail
             $query = new DeleteQuery();
             $query->setTable("dr_thumbnail");
             $query->setWhere("fk_file = '" . $this->_id->getIdString() . "'");
             $dbHandler->query($query, $this->_configuration->getProperty("database_index"));
             // Delete the data row in case we were switching from another type
             // that used it.
             $query = new DeleteQuery();
             $query->setTable("dr_file_data");
             $query->setWhere("fk_file = '" . $this->_id->getIdString() . "'");
             $dbHandler->query($query, $this->_configuration->getProperty("database_index"));
             // delete the file row.
             $query = new DeleteQuery();
             $query->setTable("dr_file");
             $query->setWhere("id = '" . $this->_id->getIdString() . "'");
             $dbHandler->query($query, $this->_configuration->getProperty("database_index"));
         } else {
             if ($field != "FILE_SIZE") {
                 $this->_parts[$field]->updateValue("NULL");
             }
         }
     } else {
         throwError(new Error(RepositoryException::UNKNOWN_ID() . ": {$string}", "FileSystemFileRecord", true));
     }
 }
 /**
  * Create a new unique identifier.
  *	
  * @return object Id
  * 
  * @throws object IdException An exception with one of the following
  *		   messages defined in org.osid.id.IdException:	 {@link
  *		   org.osid.id.IdException#OPERATION_FAILED OPERATION_FAILED},
  *		   {@link org.osid.id.IdException#PERMISSION_DENIED
  *		   PERMISSION_DENIED}, {@link
  *		   org.osid.id.IdException#CONFIGURATION_ERROR
  *		   CONFIGURATION_ERROR}, {@link
  *		   org.osid.id.IdException#UNIMPLEMENTED UNIMPLEMENTED}
  * 
  * @access public
  */
 function createId()
 {
     if (isset($this->createId_stmt)) {
         $this->createId_stmt->execute();
         $newID = $this->harmoni_db->lastInsertId('id', 'id_value');
         $this->deleteId_stmt->bindValue(1, $newID);
         $this->deleteId_stmt->execute();
     } else {
         debug::output("Attempting to generate new id.", 20, "IdManager");
         $dbHandler = Services::getService("DatabaseManager");
         $query = new InsertQuery();
         $query->setAutoIncrementColumn("id_value", "id_id_value_seq");
         $query->setTable("id");
         $query->addRowOfValues(array());
         $result = $dbHandler->query($query, $this->_dbIndex);
         if ($result->getNumberOfRows() != 1) {
             throwError(new Error(IdException::CONFIGURATION_ERROR(), "IdManager", true));
         }
         $newID = $result->getLastAutoIncrementValue();
         // Clear out any values smaller than our last one to keep the table from
         // exploding size.
         $query = new DeleteQuery();
         $query->setTable("id");
         $query->setWhere("id_value < '" . $newID . "'");
         $result = $dbHandler->query($query, $this->_dbIndex);
     }
     $newID = $this->_prefix . strval($newID);
     debug::output("Successfully created new id '{$newID}'.", DEBUG_SYS5, "IdManager");
     $id = new HarmoniId($newID);
     // cache the id
     //		$this->_ids[$newID] = $id;
     return $id;
 }
Beispiel #15
0
 /**
  * removes the style collection from the theme, and the DB is called for
  * 
  * @param boolean $removeFromDatabase whether to remove the data from the database
  * @param ref object StyleCollection $style the style
  * @return void
  * @access public
  * @since 5/16/06
  */
 function removeStyleCollection($style, $removeFromDatabase = false)
 {
     $guiManager = Services::getService("GUI");
     $dbHandler = Services::getService('DBHandler');
     $guiManager->deletePropertiesForCollection($style);
     if (is_object($style->_id)) {
         $id = $style->getId();
         $idValue = $id->getIdString();
         $query = new DeleteQuery();
         $query->setTable($guiManager->_dbName . ".tm_style_collection");
         $query->addWhere("fk_theme_id = {$idValue}");
         $result = $dbHandler->query($query, $guiManager->_dbIndex);
     }
     unset($this->_styles[$style->getSelector()]);
 }
 /**
  * Delete all properties associated with an object
  * This is here partially to preserve the option of using non-editable agents
  * If that ceases to be an issue, this more properly belongs in
  * HarmoniEditableAgent.class
  *
  * @param string $object_id_string
  * @return boolean
  * @access public
  */
 function deleteAllProperties($object_id_string)
 {
     $dbHandler = Services::getService("DBHandler");
     //create a query to remove all properties associated with $object_id_string
     $query = new DeleteQuery();
     $query->setTable("agent_properties");
     $query->addWhere("fk_object_id='{$object_id_string}'");
     $result = $dbHandler->query($query, $this->_dbIndex);
     return $result ? true : false;
 }
 /**
  * Tests the generateSQLQuery() without WHERE clause.
  */
 function test()
 {
     // insert one row
     $query = new InsertQuery();
     $query->setTable("test1");
     $query->setColumns(array("value"));
     $query->addRowOfValues(array("'Spaceboy'"));
     $query->setAutoIncrementColumn("id", "test1_id_seq");
     $result = $this->db->query($query);
     $lastId = $result->getLastAutoIncrementValue();
     // insert it again, the id must have increased by one
     $result = $this->db->query($query);
     $this->assertIdentical($result->getNumberOfRows(), 1);
     $this->assertIdentical($result->getLastAutoIncrementValue(), $lastId + 1);
     // add several rows at the same time
     $query->addRowOfValues(array("'Astrogirl'"));
     $result = $this->db->query($query);
     $this->assertIdentical($result->getLastAutoIncrementValue(), $lastId + 3);
     // now insert in the other test table
     $query = new InsertQuery();
     $query->setTable("test");
     $query->setColumns(array("FK", "value"));
     $query->addRowOfValues(array($lastId, "'Ziggy'"));
     $query->addRowOfValues(array($lastId + 1, "'Lost in the Stars'"));
     $query->addRowOfValues(array($lastId + 2, "'Headstar'"));
     $query->addRowOfValues(array($lastId + 3, "'Stardust'"));
     $query->setAutoIncrementColumn("id", "test1_id_seq");
     $result = $this->db->query($query);
     // join the inserted rows
     $query = new SelectQuery();
     $query->addTable("test1");
     $query->addTable("test", INNER_JOIN, "test.FK = test1.id");
     $query->addColumn("id", "dm86_id", "test");
     $query->addColumn("FK", "dm86_fk", "test");
     $query->addColumn("value", "dm86_value", "test");
     $query->addColumn("id", "dm98_id", "test1");
     $query->addColumn("value", "dm98_value", "test1");
     $query->addWhere("test1.id >= " . $lastId);
     $result = $this->db->query($query);
     $this->assertIdentical($result->getNumberOfRows(), 4);
     $this->assertIdentical((int) $result->field("dm86_fk"), $lastId);
     $this->assertIdentical($result->field("dm86_value"), "Ziggy");
     $this->assertIdentical((int) $result->field("dm98_id"), $lastId);
     $this->assertIdentical($result->field("dm98_value"), "Spaceboy");
     $result->advanceRow();
     $this->assertIdentical((int) $result->field("dm86_fk"), $lastId + 1);
     $this->assertIdentical($result->field("dm86_value"), "Lost in the Stars");
     $this->assertIdentical((int) $result->field("dm98_id"), $lastId + 1);
     $this->assertIdentical($result->field("dm98_value"), "Spaceboy");
     $result->advanceRow();
     $this->assertIdentical((int) $result->field("dm86_fk"), $lastId + 2);
     $this->assertIdentical($result->field("dm86_value"), "Headstar");
     $this->assertIdentical((int) $result->field("dm98_id"), $lastId + 2);
     $this->assertIdentical($result->field("dm98_value"), "Spaceboy");
     $result->advanceRow();
     $this->assertIdentical((int) $result->field("dm86_fk"), $lastId + 3);
     $this->assertIdentical($result->field("dm86_value"), "Stardust");
     $this->assertIdentical((int) $result->field("dm98_id"), $lastId + 3);
     $this->assertIdentical($result->field("dm98_value"), "Astrogirl");
     $result->free();
     $query = new UpdateQuery();
     $query->setTable("test1");
     $query->setColumns(array("value"));
     $query->setValues(array("'I changed you MF!'"));
     $query->addWhere("id = " . $lastId);
     $result = $this->db->query($query);
     $this->assertIdentical($result->getNumberOfRows(), 1);
     $query = new SelectQuery();
     $query->addTable("test1");
     $query->addColumn("value");
     $query->addWhere("test1.id = " . $lastId);
     $result = $this->db->query($query);
     $this->assertIdentical($result->getNumberOfRows(), 1);
     $this->assertIdentical($result->field("value"), "I changed you MF!");
     $result->free();
     $query = new DeleteQuery();
     $query->setTable("test1");
     $query->addWhere("id = " . $lastId);
     $result = $this->db->query($query);
     $this->assertIdentical($result->getNumberOfRows(), 1);
     $query = new SelectQuery();
     $query->addTable("test1");
     $query->addColumn("value");
     $query->addWhere("test1.id = " . $lastId);
     $result = $this->db->query($query);
     $this->assertIdentical($result->getNumberOfRows(), 0);
     $result->free();
 }
 /**
  * Delete a GradeRecord.  The first two parameters are required, but the
  * third may be left null to dignify any Type
  * 
  * @param object Id $gradableObjectId
  * @param object Id $agentId
  * @param object Type $GradeRecordType
  * 
  * @throws object GradingException An exception with one of the
  *         following messages defined in org.osid.grading.GradingException
  *         may be thrown:  {@link
  *         org.osid.grading.GradingException#OPERATION_FAILED
  *         OPERATION_FAILED}, {@link
  *         org.osid.grading.GradingException#PERMISSION_DENIED
  *         PERMISSION_DENIED}, {@link
  *         org.osid.grading.GradingException#CONFIGURATION_ERROR
  *         CONFIGURATION_ERROR}, {@link
  *         org.osid.grading.GradingException#UNIMPLEMENTED UNIMPLEMENTED},
  *         {@link org.osid.grading.GradingException#NULL_ARGUMENT
  *         NULL_ARGUMENT}, {@link
  *         org.osid.grading.GradingException#UNKNOWN_ID UNKNOWN_ID}
  * 
  * @access public
  */
 function deleteGradeRecord(Id $gradableObjectId, Id $agentId, Type $GradeRecordType)
 {
     $dbManager = Services::getService("DatabaseManager");
     $query = new DeleteQuery();
     $query->setTable('gr_record');
     $query->addWhere("fk_gr_gradable='" . addslashes($gradableObjectId->getIdString()) . "'");
     $query->addWhere("fk_agent_id='" . addslashes($agentId->getIdString()) . "'");
     if (!is_null($GradeRecordType)) {
         $query->addWhere("fk_gr_record_type='" . addslashes($this->_typeToIndex('record', $GradeRecordType)) . "'");
     }
     $dbManager->query($query);
 }
 /**
  * Remove an External group from a Hierarchy-based group.
  * 
  * @param object Id $hierarchyParentId
  * @param object Id $externalChildId
  * @return void
  * @access public
  * @since 11/6/07
  */
 public function removeExternalChildGroup(Id $hierarchyParentId, Id $externalChildId)
 {
     // Remove the row.
     $query = new DeleteQuery();
     $query->setTable('agent_external_children');
     $query->addWhereEqual('fk_parent', $hierarchyParentId->getIdString());
     $query->addWhereEqual('fk_child', $externalChildId->getIdString());
     $dbc = Services::getService("DBHandler");
     $dbc->query($query, $this->_configuration->getProperty('database_index'));
 }
Beispiel #20
0
 /**
  * Write the cache
  * 
  * @return void
  * @access public
  * @since 2/13/06
  */
 function writeCache()
 {
     $dbc = Services::getService('DatabaseManager');
     $query = new DeleteQuery();
     $query->setTable('dr_resized_cache');
     $query->addWhere("dr_resized_cache.fk_file = '" . addslashes($this->_id->getIdString()) . "'");
     $query->addWhere("dr_resized_cache.size = '" . addslashes($this->_size) . "'");
     $query->addWhere("dr_resized_cache.websafe = " . ($this->_websafe ? '1' : '0'));
     $dbc->query($query, $this->getDBIndex());
     $query = new InsertQuery();
     $query->setTable('dr_resized_cache');
     $query->setColumns(array('fk_file', 'size', 'websafe', 'cache_time', 'fk_mime_type', 'data'));
     $values = array();
     $values[] = "'" . addslashes($this->_id->getIdString()) . "'";
     $values[] = "'" . addslashes($this->_size) . "'";
     $values[] = $this->_websafe ? '1' : '0';
     $values[] = "NOW()";
     $imgProcessor = Services::getService("ImageProcessor");
     if ($this->_websafe) {
         $this->_mimeType = $imgProcessor->getWebsafeFormat($this->_parts['MIME_TYPE']->getValue());
         $values[] = $this->getMimeKey();
         $values[] = "'" . addslashes($imgProcessor->getWebsafeData($this->_parts['MIME_TYPE']->getValue(), $this->_size, $this->_parts['FILE_DATA']->getValue())) . "'";
     } else {
         $this->_mimeType = $imgProcessor->getResizedFormat($this->_parts['MIME_TYPE']->getValue());
         $values[] = $this->getMimeKey();
         $values[] = "'" . addslashes($imgProcessor->getResizedData($this->_parts['MIME_TYPE']->getValue(), $this->_size, $this->_parts['FILE_DATA']->getValue())) . "'";
     }
     $query->addRowOfValues($values);
     $dbc->query($query, $this->getDBIndex());
 }
Beispiel #21
0
 /**
  * Remove the tag everywhere where the current user has added it.
  * 
  * @return void
  * @access public
  * @since 11/2/06
  */
 function removeAllMine()
 {
     $query = new DeleteQuery();
     $query->setTable('tag');
     $query->addWhere("tag.value='" . addslashes($this->getValue()) . "'");
     $query->addWhere("tag.user_id='" . addslashes($this->getCurrentUserIdString()) . "'");
     $dbc = Services::getService("DatabaseManager");
     $dbc->query($query, $this->getDatabaseIndex());
 }
 /**
  * Remove a student from the roster.
  * 
  * @param object Id $agentId
  * 
  * @throws object CourseManagementException An exception
  *		   with one of the following messages defined in
  *		   org.osid.coursemanagement.CourseManagementException may be
  *		   thrown:	{@link
  *		   org.osid.coursemanagement.CourseManagementException#OPERATION_FAILED
  *		   OPERATION_FAILED}, {@link
  *		   org.osid.coursemanagement.CourseManagementException#PERMISSION_DENIED
  *		   PERMISSION_DENIED}, {@link
  *		   org.osid.coursemanagement.CourseManagementException#CONFIGURATION_ERROR
  *		   CONFIGURATION_ERROR}, {@link
  *		   org.osid.coursemanagement.CourseManagementException#UNIMPLEMENTED
  *		   UNIMPLEMENTED}, {@link
  *		   org.osid.coursemanagement.CourseManagementException#NULL_ARGUMENT
  *		   NULL_ARGUMENT}, {@link
  *		   org.osid.coursemanagement.CourseManagementException#UNKNOWN_ID
  *		   UNKNOWN_ID}
  * 
  * @access public
  */
 function removeStudent(Id $agentId)
 {
     $dbManager = Services::getService("DatabaseManager");
     $query = new DeleteQuery();
     $query->setTable('cm_enroll');
     $query->addWhere("fk_cm_section='" . addslashes($this->_id->getIdString()) . "'");
     $query->addWhere("fk_student_id='" . addslashes($agentId->getIdString()) . "'");
     $dbManager->query($query);
 }
 /**
  * Store a mapping between Segue1 ids and Segue2 ids
  * 
  * @return void
  * @access protected
  * @since 3/20/08
  */
 protected function storeSegue1IdMapping()
 {
     if (!isset($this->origenSlotname)) {
         throw new OperationFailedException("Origen slot not set. Call " . get_class($this) . "->setOrigenSlotname('xxxxx').");
     }
     if (!isset($this->destSlotname)) {
         throw new OperationFailedException("Destination slot not set. Call " . get_class($this) . "->setDestinationSlotname('xxxxx').");
     }
     $dbc = Services::getService('DatabaseManager');
     $map = $this->filterNonAccessible($this->getIdMap());
     // 		printpre(htmlentities($this->doc->saveXMLWithWhitespace()));
     // 		printpre($map);
     // 		throw new Exception('test');
     // Delete any old mappings
     $query = new DeleteQuery();
     $query->setTable('segue1_id_map');
     $query->addWhereIn('segue1_id', array_keys($map));
     $dbc->query($query, IMPORTER_CONNECTION);
     // Add new mappings
     $query = new InsertQuery();
     $query->setTable('segue1_id_map');
     foreach ($map as $segue1Id => $segue2Id) {
         $query->createRow();
         $query->addValue('segue1_slot_name', $this->origenSlotname);
         $query->addValue('segue1_id', $segue1Id);
         $query->addValue('segue2_slot_name', $this->destSlotname);
         $query->addValue('segue2_id', $segue2Id);
     }
     $dbc->query($query, IMPORTER_CONNECTION);
 }
 /**
  * Delete the specified CourseGradeRecord by Id. courseGradeRecordId
  *
  * @param object Id $courseGradeRecordId
  *
  * @throws object CourseManagementException An exception
  *		   with one of the following messages defined in
  *		   org.osid.coursemanagement.CourseManagementException may be
  *		   thrown:	{@link
  *		   org.osid.coursemanagement.CourseManagementException#OPERATION_FAILED
  *		   OPERATION_FAILED}, {@link
  *		   org.osid.coursemanagement.CourseManagementException#PERMISSION_DENIED
  *		   PERMISSION_DENIED}, {@link
  *		   org.osid.coursemanagement.CourseManagementException#CONFIGURATION_ERROR
  *		   CONFIGURATION_ERROR}, {@link
  *		   org.osid.coursemanagement.CourseManagementException#UNIMPLEMENTED
  *		   UNIMPLEMENTED}, {@link
  *		   org.osid.coursemanagement.CourseManagementException#NULL_ARGUMENT
  *		   NULL_ARGUMENT}, {@link
  *		   org.osid.coursemanagement.CourseManagementException#UNKNOWN_ID
  *		   UNKNOWN_ID}
  *
  * @access public
  */
 function deleteCourseGradeRecord(Id $courseGradeRecordId)
 {
     ArgumentValidator::validate($courseGradeRecordId, ExtendsValidatorRule::getRule("Id"), true);
     $dbManager = Services::getService("DatabaseManager");
     $query = new DeleteQuery();
     $query->setTable('cm_grade_rec');
     $query->addWhere("id=" . addslashes($courseGradeRecordId->getIdString()));
     $dbManager->query($query);
 }
 /**
  * Remove the mapping between AuthNTokens and an Agent
  * 
  * @param object AgentTokenMapping $mapping
  * @return void
  * @access public
  * @since 3/9/05
  */
 function deleteMapping(AgentTokenMapping $mapping)
 {
     $this->_checkConfig();
     $dbc = Services::getService("DatabaseManager");
     $dbc->beginTransaction($this->_dbId);
     $agentId = $mapping->getAgentId();
     $authNTokens = $mapping->getTokens();
     $typeKey = $this->_getTypeKey($mapping->getAuthenticationType());
     // Delete the mapping.
     $query = new DeleteQuery();
     $query->setTable($this->_mappingTable);
     $query->addWhere("agent_id='" . addslashes($agentId->getIdString()) . "'");
     $query->addWhere("token_identifier='" . addslashes($authNTokens->getIdentifier()) . "'", _AND);
     $query->addWhere("fk_type='" . addslashes($typeKey) . "'", _AND);
     $result = $dbc->query($query, $this->_dbId);
     // Delete the type if nothing is referencing it.
     $query = new SelectQuery();
     $query->addTable($this->_mappingTable);
     $query->addColumn("COUNT(*)", "count");
     $query->addWhere("fk_type='" . addslashes($typeKey) . "'");
     $result = $dbc->query($query, $this->_dbId);
     if ($result->getNumberOfRows() == 0) {
         $query = new DeleteQuery();
         $query->addTable($this->_typeTable);
         $query->addWhere("id='" . addslashes($typeKey) . "'");
         $result = $dbc->query($query, $this->_dbId);
     }
     $result->free();
     $dbc->commitTransaction($this->_dbId);
 }
 /**
  * Clear the ancestory rows for a given node
  * 
  * @param string $idString
  * @return void
  * @access public
  * @since 11/4/05
  */
 function clearNodeAncestory($idString)
 {
     // Delete the old ancestory
     if (isset($this->harmoni_db)) {
         if (!isset($this->clearNodeAncestory_stmt)) {
             $query = $this->harmoni_db->delete();
             $query->setTable("az2_node_ancestry");
             $query->addWhereRawEqual("fk_hierarchy", '?');
             $query->addWhereRawEqual("fk_node", '?');
             $this->clearNodeAncestory_stmt = $query->prepare();
         }
         $this->clearNodeAncestory_stmt->bindValue(1, $this->_hierarchyId);
         $this->clearNodeAncestory_stmt->bindValue(2, $idString);
         $this->clearNodeAncestory_stmt->execute();
     } else {
         $dbHandler = Services::getService("DatabaseManager");
         $query = new DeleteQuery();
         $query->setTable("az2_node_ancestry");
         $query->addWhereEqual("fk_hierarchy", $this->_hierarchyId);
         $query->addWhereEqual("fk_node", $idString);
         $queryResult = $dbHandler->query($query, $this->_dbIndex);
     }
 }
 /**
  * Update the value for this Part.
  * 
  * @param object mixed $value (original type: java.io.Serializable)
  * 
  * @throws object RepositoryException An exception with one of
  *		   the following messages defined in
  *		   org.osid.repository.RepositoryException may be thrown: {@link
  *		   org.osid.repository.RepositoryException#OPERATION_FAILED
  *		   OPERATION_FAILED}, {@link
  *		   org.osid.repository.RepositoryException#PERMISSION_DENIED
  *		   PERMISSION_DENIED}, {@link
  *		   org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  *		   CONFIGURATION_ERROR}, {@link
  *		   org.osid.repository.RepositoryException#UNIMPLEMENTED
  *		   UNIMPLEMENTED}, {@link
  *		   org.osid.repository.RepositoryException#NULL_ARGUMENT
  *		   NULL_ARGUMENT}
  * 
  * @access public
  */
 function updateValue($value)
 {
     //		ArgumentValidator::validate($value, StringValidatorRule::getRule());
     $dbHandler = Services::getService("DatabaseManager");
     // Delete the row if we are setting the value to null
     if (is_null($value)) {
         $query = new DeleteQuery();
         $query->setTable("dr_file_data");
         $query->addWhere("fk_file = '" . $this->_recordId->getIdString() . "'");
         $dbHandler->query($query, $this->_configuration->getProperty("database_index"));
         $this->_asset->updateModificationDate();
         return;
     }
     // Store the data in the object in case its asked for again.
     //		$this->_data = $value;
     // Make sure that the dr_file row is inserted.
     $query = new InsertQuery();
     $query->setTable("dr_file");
     $query->addValue("id", $this->_recordId->getIdString());
     try {
         $dbHandler->query($query, $this->_configuration->getProperty("database_index"));
     } catch (QueryDatabaseException $e) {
         // If an error is thrown inserting (because the file already exists)
         // ignore it.
     }
     $dbHandler->beginTransaction($this->_configuration->getProperty("database_index"));
     // Base64 encode the data to preserve it,
     // then write it to the database.
     // Check to see if the data is in the database
     $query = new SelectQuery();
     $query->addTable("dr_file_data");
     $query->addColumn("COUNT(*) as count");
     $query->addWhere("fk_file = '" . $this->_recordId->getIdString() . "'");
     $result = $dbHandler->query($query, $this->_configuration->getProperty("database_index"));
     // If it already exists, use an update query.
     if ($result->field("count") > 0) {
         $query = new UpdateQuery();
         $query->setTable("dr_file_data");
         $query->setColumns(array("data"));
         $query->setValues(array("'" . base64_encode($value) . "'"));
         $query->addWhere("fk_file = '" . $this->_recordId->getIdString() . "'");
     } else {
         $query = new InsertQuery();
         $query->setTable("dr_file_data");
         $query->setColumns(array("fk_file", "data"));
         $query->setValues(array("'" . $this->_recordId->getIdString() . "'", "'" . base64_encode($value) . "'"));
     }
     $result->free();
     //		printpre($query);
     //		printpre(MySQL_SQLGenerator::generateSQLQuery($query));
     // run the query
     $dbHandler->query($query, $this->_configuration->getProperty("database_index"));
     // Update the size row.
     $query = new UpdateQuery();
     $query->setTable("dr_file");
     $query->addValue("size", strval(strlen($value)));
     $query->addWhereEqual("id", $this->_recordId->getIdString());
     $dbHandler->query($query, $this->_configuration->getProperty("database_index"));
     $dbHandler->commitTransaction($this->_configuration->getProperty("database_index"));
     $this->_asset->updateModificationDate();
 }
 function test_All_Queries()
 {
     $value = "'Depeche Mode rocks!'";
     $this->dbhandler->connect();
     // create a new queue of queries to execuete
     $queryQueue = new Queue();
     $query = new InsertQuery();
     $query->setTable("test1");
     $query->setColumns(array("value"));
     $query->addRowOfValues(array($value));
     $queryQueue->add($query);
     $query = new InsertQuery();
     $query->setTable("test1");
     $query->setColumns(array(id, value));
     $query->addRowOfValues(array("3000000", $value));
     $queryQueue->add($query);
     $query = new DeleteQuery();
     $query->setTable("test1");
     $query->setWhere("id = 3000000");
     $queryQueue->add($query);
     $query = new UpdateQuery();
     $query->setTable("test1");
     $query->setColumns(array("value"));
     $query->setValues(array($value));
     $query->setWhere("id > 1000 AND id < 1006");
     $queryQueue->add($query);
     $resultQueue = $this->dbhandler->queryQueue($queryQueue);
     $this->assertEqual($this->dbhandler->getTotalNumberOfQueries(), 4);
     $this->assertEqual($this->dbhandler->getTotalNumberOfSuccessfulQueries(), 4);
     $this->assertEqual($this->dbhandler->getTotalNumberOfFailedQueries(), 0);
     $result = $resultQueue->next();
     $this->assertEqual($result->getNumberOfRows(), 1);
     $this->assertNotNull($result->getLastAutoIncrementValue());
     $id = $result->getLastAutoIncrementValue();
     $result = $resultQueue->next();
     $this->assertEqual($result->getNumberOfRows(), 1);
     $this->assertNotNull($result->getLastAutoIncrementValue());
     $result = $resultQueue->next();
     $this->assertEqual($result->getNumberOfRows(), 1);
     $result = $resultQueue->next();
     $query = new SelectQuery();
     $query->setColumns(array("value"));
     $query->addTable("test1");
     $query->setWhere("id = {$id}");
     $result = $this->dbhandler->query($query);
     $this->assertEqual($this->dbhandler->getTotalNumberOfQueries(), 5);
     $this->assertEqual($this->dbhandler->getTotalNumberOfSuccessfulQueries(), 5);
     $this->assertEqual($this->dbhandler->getTotalNumberOfFailedQueries(), 0);
     $this->assertEqual("'" . $result->field("value") . "'", $value);
     $result->free();
 }
 /**
  * Delete a Part and all its Parts.
  * 
  * @param object Id $partId
  * 
  * @throws object RepositoryException An exception with one of
  *		   the following messages defined in
  *		   org.osid.repository.RepositoryException may be thrown: {@link
  *		   org.osid.repository.RepositoryException#OPERATION_FAILED
  *		   OPERATION_FAILED}, {@link
  *		   org.osid.repository.RepositoryException#PERMISSION_DENIED
  *		   PERMISSION_DENIED}, {@link
  *		   org.osid.repository.RepositoryException#CONFIGURATION_ERROR
  *		   CONFIGURATION_ERROR}, {@link
  *		   org.osid.repository.RepositoryException#UNIMPLEMENTED
  *		   UNIMPLEMENTED}, {@link
  *		   org.osid.repository.RepositoryException#NULL_ARGUMENT
  *		   NULL_ARGUMENT}, {@link
  *		   org.osid.repository.RepositoryException#UNKNOWN_ID UNKNOWN_ID}
  * 
  * @access public
  */
 function deletePart(Id $partId)
 {
     $string = $partId->getIdString();
     if (preg_match("/(.*)-(" . implode("|", array_keys($this->_parts)) . ")/", $string, $r)) {
         $recordId = $r[1];
         $field = $r[2];
         if ($this->_isLastPart($field)) {
             $dbHandler = Services::getService("DatabaseManager");
             // Delete the data
             $query = new DeleteQuery();
             $query->setTable("dr_file_url");
             $query->setWhere("fk_file = '" . $this->_id->getIdString() . "'");
             $dbHandler->query($query, $this->_configuration->getProperty("database_index"));
             // Delete the thumbnail
             $query = new DeleteQuery();
             $query->setTable("dr_thumbnail");
             $query->setWhere("fk_file = '" . $this->_id->getIdString() . "'");
             $dbHandler->query($query, $this->_configuration->getProperty("database_index"));
             // delete the file row.
             $query = new DeleteQuery();
             $query->setTable("dr_file");
             $query->setWhere("id = '" . $this->_id->getIdString() . "'");
             $dbHandler->query($query, $this->_configuration->getProperty("database_index"));
         } else {
             $this->_parts[$field]->updateValue("NULL");
         }
     } else {
         throwError(new Error(RepositoryException::UNKNOWN_ID() . ": {$string}", "FileRecord", true));
     }
     $this->_asset->updateModificationDate();
 }
 /**
  * Delete the log with the specified name.
  * 
  * @param string $logName
  * 
  * @throws object LoggingException An exception with one of the
  *		   following messages defined in org.osid.logging.LoggingException
  *		   may be thrown:  {@link
  *		   org.osid.logging.LoggingException#UNIMPLEMENTED UNIMPLEMENTED},
  *		   {@link org.osid.logging.LoggingException#OPERATION_FAILED
  *		   OPERATION_FAILED}, {@link
  *		   org.osid.logging.LoggingException#CONFIGURATION_ERROR
  *		   CONFIGURATION_ERROR}, {@link
  *		   org.osid.logging.LoggingException#PERMISSION_DENIED
  *		   PERMISSION_DENIED}, {@link
  *		   org.osid.logging.LoggingException#UNKNOWN_NAME UNKNOWN_NAME}
  * 
  * @access public
  */
 function deleteLog($logName)
 {
     $log = $this->getLogForWriting($logName);
     $log = null;
     $dbc = Services::getService("DatabaseManager");
     // get the entry Ids
     $query = new SelectQuery();
     $query->addColumn("id");
     $query->addTable("log_entry");
     $query->addWhere("log_name = '" . addslashes($logName) . "'");
     $result = $dbc->query($query, $this->_dbIndex);
     $entryIds = array();
     while ($result->hasMoreRows()) {
         $entryIds[] = "'" . addslashes($result->field("id")) . "'";
         $result->advanceRow();
     }
     $result->free();
     // delete the agent keys
     $query = new DeleteQuery();
     $query->setTable("log_agent");
     $query->addWhere("fk_entry IN (" . implode(", ", $entryIds) . ")");
     $dbc->query($query, $this->_dbIndex);
     // delete the node keys
     $query->setTable("log_node");
     $dbc->query($query, $this->_dbIndex);
     // delete the entries
     $query = new DeleteQuery();
     $query->setTable("log_entry");
     $query->addWhere("log_name = '" . addslashes($logName) . "'");
     $dbc->query($query, $this->_dbIndex);
 }