All pastes #628054 Raw Edit

janetgo2

public php v1 · immutable
·published 2007-07-20 18:19 UTC
rendered paste body
/* getLatestInventoryLocationID($item_id) * Gets InventoryLocations id for latest move for designated item_id * $item_id - the id of the Inventory Item */function getLatestInventoryLocationID($item_id) {	if(MYSQL) {		$latest_move_sql = "SELECT InventoryLocations.id												FROM csis.InventoryLocations												WHERE InventoryLocations.item_id = {0}												ORDER BY InventoryLocations.time_moved DESC												LIMIT 1 ";		$safe_latest_move_sql = prepareSQL($latest_move_sql,array($item_id));		$latest_move_result = mysql_query($safe_latest_move_sql) or dbError(mysql_error(), $safe_latest_move_sql);		$num_latest_moves = mysql_num_rows($latest_move_result);				if($num_latest_moves == 1)			$latest_move_id = mysql_result($latest_move_result,0,"InventoryLocations.id");				return $latest_move_id;	}}/* getItemLocationRoomID($item_id) * Gets full Room name of Inventory Item with designated item_id * $item_id - the id of the Inventory Item */function getItemLocationRoomID($item_id) {	if(MYSQL) {		$latest_move_id = getLatestInventoryLocationID($item_id);		$inventory_sql = "SELECT InventoryLocations.room_id											FROM csis.InventoryLocations											WHERE InventoryLocations.id = {0}";		$safe_sql = prepareSQL($inventory_sql, array($latest_move_id));		$inventory_result = mysql_query($safe_sql) or dbError(mysql_error(), $safe_sql);		$inventory_num_rows = mysql_num_rows($inventory_result);				if($inventory_num_rows == 1) { // If query succeeded			$latest_room_id = mysql_result($inventory_result,0,"room_id");		}				return $latest_room_id;	}}?>