Ejemplo n.º 1
0
function outputStudents()
{
    $conn = database_connect();
    //$conn = mysqli_connect(DATABASE_HOST, DATABASE_USER, DATABASE_PASS, DATABASE_HOME);
    $query = "SELECT seatNumber,name,md5hash FROM students";
    $result = mysqli_query($conn, $query);
    if (mysqli_errno($conn)) {
        echo mysqli_error($conn);
    }
    echo '<pre>';
    while ($row = mysqli_fetch_array($result)) {
        // print_r($row);
        if ($row['seatNumber'] == $_SESSION['runCounter']) {
            echo "CURRENT:\t";
        } else {
            if ($row['seatNumber'] % 2 == 1) {
                echo "ODD:\t";
            } else {
                echo "EVEN:\t";
            }
        }
        echo $row['seatNumber'] . "\t" . $row['name'] . '<br>';
    }
    echo '</pre>';
    $numRows = mysqli_num_rows($result);
    if ($_SESSION['runCounter'] > $numRows) {
        $_SESSION['runCounter'] = 1;
    }
    database_disconnect($conn);
}
function search_infoTable($chemicals)
{
    if (!database_connect()) {
        return "DB_CONNECT_FAILURE";
    }
    if (empty($chemicals)) {
        return "NO_SEARCH";
    }
    # Set up parameters of a basic chemicalSGA search
    $search = "chemicalConditions.*, chemicals.structure_pic";
    $table = "chemicalConditions, chemicals";
    #Build the where statement
    $andQueryArray = array();
    if (!empty($chemicals)) {
        array_push($andQueryArray, "chemicalConditions.chemical_name IN " . build_IN_LIST($chemicals));
    }
    //array_push($andQueryArray, build_OR($chemicals, "chemicalConditions.chemical_name='", "'"));}
    array_push($andQueryArray, 'chemicalConditions.chemical_name = chemicals.name');
    $where = build_AND($andQueryArray);
    //echo($where);
    //print $where;
    #Do the search
    $result = database_select_distinct_search($search, $table, $where);
    # Throw the results into an array
    $resultArray = array();
    while ($row = mysql_fetch_assoc($result)) {
        array_push($resultArray, $row);
    }
    #database dc
    database_disconnect();
    #return the results array
    if (count($resultArray) == 0) {
        return "EMPTY";
    }
    # Is the array empty?
    return $resultArray;
}
$gene = safe($_POST['gene']);
$needAnd = false;
$search = "*";
$table = "interactions";
$sortedBy = "chemgen_score";
$where = "";
if ($drug != "") {
    $where .= ($needAnd ? "AND " : "") . "drug_name = '{$drug}' ";
    $needAnd = true;
}
if ($gene != "") {
    $where .= ($needAnd ? "AND " : "") . "(orf_name = '{$gene}' OR common_name = '{$gene}') ";
    $needAnd = true;
}
//$where = "drug_name = '$drug' AND (orf_name = '$gene' OR common_name = '$gene')";
if ($drug != "" || $gene != "") {
    #Do a database search
    $result = database_select_search($search, $table, $where, $sortedBy);
    # Throw the results into an array
    $resultArray = array();
    while ($row = mysql_fetch_assoc($result)) {
        array_push($resultArray, $row);
    }
    # jsonencore ajax the array back
    echo json_encode($resultArray);
} else {
    echo "NO_SEARCH";
}
# DC from database
database_disconnect();
Ejemplo n.º 4
0
<?php

include "config/config.php";
include "functions/database.fn.php";
include "functions/session.fn.php";
session_start();
$db['link'] = database_connect($db);
$connected_user_name = session_get_uname();
$connected_user_id = session_get_uid();
database_disconnect($db['link']);
include 'templates/home.html';
function search_info_GO_terms($GO_terms)
{
    if (!database_connect()) {
        return "DB_CONNECT_FAILURE";
    }
    if (empty($GO_terms)) {
        return array();
    }
    # Set up parameters
    $search = "*";
    $table = $GLOBALS['TABLE_GO_NAMES'];
    #Build the where statement
    $where = "0 = 1";
    if (!empty($GO_terms)) {
        $where = "pid IN " . build_IN_LIST($GO_terms);
    }
    #Do the search
    $result = database_select_distinct_search($search, $table, $where);
    # Throw the results into an array
    $resultArray = array();
    while ($row = mysql_fetch_assoc($result)) {
        $row["searchType"] = "GO";
        array_push($resultArray, $row);
    }
    #database dc
    database_disconnect();
    #return the results array
    if (count($resultArray) == 0) {
        return "EMPTY";
    }
    # Is the array empty?
    return $resultArray;
}
function getGOList()
{
    #Connect to the database
    if (!database_connect()) {
        echo "DB_CONNECT_FAILURE";
        return false;
    }
    #Search for name column in table chemicasl
    $search = "GO_name, GO_desc";
    $table = $GLOBALS['TABLE_GO_NAMES'];
    #Do a database search
    $result = database_select_distinct_search($search, $table);
    # Throw the results into an array
    $resultArray = array();
    while ($row = mysql_fetch_assoc($result)) {
        if ($row['GO_name'] != null) {
            array_push($resultArray, $row['GO_name']);
        }
        if ($row['GO_desc'] != null) {
            array_push($resultArray, $row['GO_desc']);
        }
    }
    # DC from database
    database_disconnect();
    #return results
    return array_unique($resultArray);
}
function getGeneOntologyDatabaseIDs($terms)
{
    #Connect to the database
    if (!database_connect()) {
        echo "DB_CONNECT_FAILURE";
        return false;
    }
    if (empty($terms)) {
        return array();
    }
    $search = "pid";
    $table = $GLOBALS['TABLE_GO_NAMES'];
    #Build the where statement
    $orQueryArray = array();
    if (!empty($terms)) {
        array_push($orQueryArray, "GO_name IN " . build_IN_LIST($terms));
    }
    if (!empty($terms)) {
        array_push($orQueryArray, "GO_desc IN " . build_IN_LIST($terms));
    }
    $where = build_OR($orQueryArray);
    #Do the search
    $result = database_select_distinct_search($search, $table, $where);
    # Throw the results into an array
    $resultArray = array();
    while ($row = mysql_fetch_assoc($result)) {
        array_push($resultArray, $row["pid"]);
    }
    #database dc
    database_disconnect();
    #return the results array
    #if(count($resultArray) == 0){return "EMPTY";}	# Is the array empty?
    return $resultArray;
}