Ignore:
Timestamp:
03/24/21 22:28:33 (4 years ago)
Author:
tbretz
Message:
Updated mysql calls.
Location:
trunk/FACT++/www/schedule
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/www/schedule/load.php

    r18720 r20052  
    99// ================================================================
    1010
    11 function query($query)
     11function query($sql, $query)
    1212{
    13    $sql = mysql_query($query);
     13   $sql = $sql->query($query);
    1414   if (!$sql)
    15         die(mysql_error());
     15        die($sql->error);
    1616
    1717   $rows = array();
    18    while($row = mysql_fetch_assoc($sql))
     18   while($row = $sql->fetch_assoc())
    1919      $rows[] = $row;
    2020
     
    4343require_once 'config.php';
    4444
    45 $db = mysql_connect($dbhost,$dbuser,$dbpass);
    46 if (!$db)
    47    die(mysql_error());
     45$sql = new mysqli($dbhost, $dbuser, $dbpass);
    4846
    49 if (!mysql_select_db($dbname, $db))
    50    die(mysql_error());
     47if ($sql->connect_error)
     48    die($sql->connect_error);
     49
     50if (!$sql->select_db($dbname))
     51    die($sql->error);
    5152
    5253/*mixed date_sunrise ( int $timestamp [, int $format = SUNFUNCS_RET_STRING [, float $latitude = ini_get("date.default_latitude") [, float $longitude = ini_get("date.default_longitude") [, float $zenith = ini_get("date.sunrise_zenith") [, float $gmt_offset = 0 ]]]]] )*/
    5354
    54 query("SELECT DISTINCT(DATE(ADDTIME(fStart, '-12:00'))) AS 'd' FROM Schedule");
    55 query("SELECT fSourceKEY AS 'key', fSourceName AS 'val' FROM Source WHERE fSourceTypeKEY=1");
    56 query("SELECT fMeasurementTypeKEY AS 'key', fMeasurementTypeName AS 'val' FROM MeasurementType");
    57 query("SELECT * FROM Schedule WHERE DATE(ADDTIME(fStart, '-12:00:00')) = '".$_POST['n']."'".$cut."ORDER BY fStart ASC, fMeasurementID ASC");
     55query($sql, "SELECT DISTINCT(DATE(ADDTIME(fStart, '-12:00'))) AS 'd' FROM Schedule");
     56query($sql, "SELECT fSourceKEY AS 'key', fSourceName AS 'val' FROM Source WHERE fSourceTypeKEY=1");
     57query($sql, "SELECT fMeasurementTypeKEY AS 'key', fMeasurementTypeName AS 'val' FROM MeasurementType");
     58query($sql, "SELECT * FROM Schedule WHERE DATE(ADDTIME(fStart, '-12:00:00')) = '".$_POST['n']."'".$cut."ORDER BY fStart ASC, fMeasurementID ASC");
    5859
    5960//sleep(3);
  • trunk/FACT++/www/schedule/save.php

    r18797 r20052  
    134134// ================================================================
    135135
    136 $db = mysql_connect($dbhost,$dbuser,$dbpass);
    137 if (!$db)
    138     die(mysql_error());
    139 
    140 if (!mysql_select_db($dbname, $db))
    141     die(mysql_error());
     136$db = new mysqli($dbhost,$dbuser,$dbpass);
     137if ($db->connect_error)
     138    die($db->connect_error);
     139
     140if (!$db->select_db($dbname))
     141    die($db->error);
    142142
    143143$query = "SELECT * FROM MeasurementType";
    144144
    145 $sql = mysql_query($query);
     145$sql = $db->query($query);
    146146if (!$sql)
    147     die(mysql_error());
     147    die($db->error);
    148148
    149149$measurements = array();
    150 while($row = mysql_fetch_assoc($sql))
     150while($row = $db->fetch_assoc($sql))
    151151    $measurements[$row['fMeasurementTypeKey']] = $row;
    152152
     
    271271
    272272foreach ($queries as $query)
    273     if (!mysql_query($query))
    274         die(mysql_error());
    275 
    276 mysql_close($db);
     273    if (!$db->query($query))
     274        die($sql->error);
     275
     276$db->close();
    277277
    278278?>
Note: See TracChangeset for help on using the changeset viewer.