$sm = $conn->getSchemaManager();
$sequences = $sm->listSequences('sit_alghero');
foreach ($sequences as $sequence) {
    if(strpos($sequence->getName(),'pe.avvioproc')!==FALSE) {
		$sql="select currval('".$sequence->getName()."') as lastid;";
		$lastid = $conn->fetchColumn($sql);

	}
			
}*/
$arrDati = array('pratica' => 32087, 'role' => 'rdp', 'utente' => 48, 'data' => 'now', 'tmsins' => time(), 'uidins' => 48, "note" => null);
//$sql="INSERT INTO pe.wf_roles(pratica,role,utente,data,uidins,tmsins) VALUES($this->pratica,$r,$usr,$data,$this->userid,$t);";
//$db->sql_query($sql);
//
print $conn->insert('pe.wf_roles', $arrDati);
$seq = getSequence('pe.wf_roles', $conn);
print $seq;
/*try{
print $conn->delete('pe.wf_roles', Array("pratica"=>32087,'role'=>'rdp'));
}
catch(Exception $e){
	print_r($e->errorInfo[2]);
}*/
/*$sql = "SELECT * FROM pe.avvioproc;";
$stmt = $conn->query($sql);
$i=0;
while ($row = $stmt->fetch()) {
	$i++;
    echo "<p>$i) Numero :".$row['numero']."</p>";
}*/
?>
	</head>
	
	<body>
		<h1>OCDAP Restriction Map </h1>
		
		<script>
			<?php 
//calls cleanCutSite fxn in clean_cutsite.php file
//finds and sets javascript values for subString, subLength, beginCutIndex, endCutIndex, highlightWidth, and bluntCut
//must send the startString as a parameter
cleanCutSite($startString);
//calls getSequence fxn in get_sequence.php file
//retrieves gene sequence info from NCBI
//finds and sets javascript values for bigString, bigArray, and bigLength
//must send the geneID as a parameter
getSequence($geneID);
?>
			
			//calls makeComp fxn from make_comp.js
			//creates and sets an array object of nucleotides (compArray) that are complementary to those from bigArray
			//must send bigArray and bigLength as parameters
			compArray = new makeComp(bigArray, bigLength);
			
			//update subArray to hold all the characters within subString
			subArray = subString.split("");
			
			//calls findSubString fxn from select_find_cutsites.js
			//looks through bigArray for all instances of subArray
			//stores starting index values of subString locations in indexFound[]
			//must send subArray, bigLength, and subLength as parameters
			posFound = new findSubString(subArray, bigLength, subLength);
<?php

echo getSequence('test', '/temp');
function getSequence($name, $folder = '/tmp', $default = 0)
{
    // Build a filename from the folder and sequence name
    $filename = realpath($folder) . '/' . $name . '.seq';
    // Open the file
    $fp = fopen($filename, "a+");
    // Lock the file so no other processes can use it
    if (flock($fp, LOCK_EX)) {
        // Fetch the current number from the file
        $num = trim(stream_get_contents($fp));
        // Check that what we read from the file was a number
        if (!ctype_digit($num)) {
            // If its not a number, lets reset to the default value
            $newnum = $default;
        } else {
            // If its a number, increment it
            $newnum = $num + 1;
        }
        // Delete the contents of the file
        ftruncate($fp, 0);
        rewind($fp);
        // Write the new number to the file
        fwrite($fp, "{$newnum}\n");
        // Release the lock
        flock($fp, LOCK_UN);
    } else {
        echo "Couldn't get the lock!";
    }