Exemplo n.º 1
0
<HTML>
	<BODY>
	<?php 
//mysql_connect("127.0.0.1:3306", "root", "madmax1.") or die(mysql_error());
//mysql_select_db("mydb") or die(mysql_error());
include "../common/functions.php";
db_utility::db_connect();
function getmaxprimarykey($tablename)
{
    $select = 'select primary_key from ' . $tablename . ' order by primary_key DESC';
    $results = mysql_query($select) or die("Failed Query of " . $select);
    $firstrow = mysql_fetch_array($results);
    return $firstrow['primary_key'];
}
function check_dataset_exists($dataset)
{
    $select = 'select count(data_set) from job_info where data_set=\'' . $dataset . '\'';
    $results = mysql_query($select) or die("Failed Query of " . $select);
    $firstrow = mysql_fetch_array($results);
    if ($firstrow['count(data_set)'] > 0) {
        die("Data_set name already exists. Terminating.");
    }
}
function insertarrayintodb($array, $tablename)
{
    $fields = "";
    $values = "";
    for ($i = 0; $i < sizeof($array); ++$i) {
        $val = $array[$i]['value'];
        if (!is_null($val) && !empty($val)) {
            if (!empty($fields)) {
Exemplo n.º 2
0
 static function pageCounter()
 {
     $uri = $_SERVER['REQUEST_URI'];
     if (strpos($uri, '?') != false) {
         $uri = substr($uri, 0, strpos($uri, '?'));
     }
     db_utility::db_connect();
     $query1 = "select hits from page_counters where uri='" . $uri . "'";
     $result1 = mysql_query($query1) or die("Failed Query of " . $query1);
     $row1 = mysql_fetch_array($result1);
     if ($row1 == null) {
         $query2 = "insert into page_counters (uri,hits) values ('" . $uri . "',1)";
     } else {
         $query2 = "update page_counters set hits=" . ($row1['hits'] + 1) . " where uri='" . $uri . "'";
     }
     mysql_query($query2) or die("Failed Query of " . $query2);
 }