<?php
function buildBasicLabelSql($searchtext, $casesense, $paramName, $wholeword){

	$query = "select instance as $paramName from instances where ";
	if ($casesense){
		$query .= "label ";
	}
	else{
		$query .= "lower(label) ";
	}

	if ($wholeword){
		if ($casesense)
			$query .= " = '$searchtext'";
		else
			$query .= " = lower('$searchtext')";
	}
	else{
		if ($casesense)
			$query .= " LIKE '%$searchtext%'";
		else
			$query .= " LIKE lower('%$searchtext%')";
	}
	return $query;
}

function buildDeleteLabelSql($element){
	$query = "delete from instances where instance=\"$element\"";
	return $query;
}

function buildInsertLabelSql($qname, $label){

	$query = "insert into instances (instance, label) values ('$qname', '$label')";
	return $query;
}

?>