Getting Record ID

I'm developing a plug in for Omeka, and I want to add another database entry in a different table after the initial insertion. Is there a code/omeka function that I can get to callback the record_id?

I'm speaking specifically of the record_id field which I see in the db_omeka_element_texts table.

Am I missing something obvious?


I would look at the ElementText.php, ElementTextTable.php, Item.php, and RecordType.php files in the application/models directory.

Each kind of object (like items, collections, tags, etc.) has a model of its own, and most model's have a table class that defines functions for finding those objects in the database tables.

Here's an example of of how to find an item associated with a known element text id.

function getItemFromElementTextId($elementTextId) {

	// set item to null by default
	$item = null;

	// get the database object
	$db = get_db();

	// get the element text table object
	$elementTextTable = $db->getTable('ElementText');

	// get the element text object from the database
	$elementText = $elementTextTable->find($elementTextId);

	// make sure the element text exists
	if ($elementText) {
		$recordType = $db->getTable('RecordType')->find($elementText->record_type_id);

		// make sure the record type for the element exists
		if ($recordType) {
			if ($recordType->name == 'Item') {

			 	// get the item associated with the record_id
				$item = $db->getTable('Item')->find($elementText->record_id);

	return $item;

$elementTextId = 1;
$item = getItemFromElementTextId($elementTextId);

Let me know if this helps.