Page MenuHomec4science

getGenes.php
No OneTemporary

File Metadata

Created
Thu, Sep 5, 09:39

getGenes.php

<?php
// case sensitive % stands for .*
//select *
//from gene_values
//where gene_value LIKE '%A1%' //
//LIMIT 20
// case insensitive with regex
//select *
//from gene_values
//where gene_value ~* '.*a1.*'
//LIMIT 20
include 'sqlConnection.php';
// get the row which contains all the values of the passed annotation
$query =
"SELECT gene_value
FROM gene_values
WHERE gene_value ~* '.*" . $_GET["gene"] .".*'
LIMIT " . $_GET["limit"];
$result = pg_query($conn, $query);
if (!$result) {
echo "An error occurred while querying the database.\n";
exit;
}
// In json format return the list of genes
$geneList = "";
while ($row = pg_fetch_row($result)) {
$geneList .= "\"$row[0]\",";
}
// drop the last comma and concatenate in json format
echo "[" . substr($geneList, 0, -1) . "]";

Event Timeline