protected function setUp() { $db = \dbFacile\factory::mysqli(); $db->open('dbFacile', 'dbfacile', 'dbfacile'); $db->execute('drop table if exists users'); $db->execute('drop table if exists tags'); $db->execute('create table users (id int(11) primary key auto_increment, name text, added int(11))'); $db->execute('create table tags (itemId int(11) primary key, tag text)'); $this->db = $db; }
<?php // Open a mysql connection require '../thi-autoload.php'; $db = \dbFacile\factory::mysqli(); $db->open('database', 'username', 'password'); /* TABLES: timers, counters, gauges - timestamp (seconds) - key (string) - value (integer) */ // set content-type to json function get_condense_key($group, $ts) { $parts = explode(' ', $group); $num = array_shift($parts); $unit = array_shift($parts); if ($unit == 'minute') { if ($num == 1) { $key = date('Y-m-d H:i', $ts); } else { $minute = floor(date('i', $ts) / $num); $key = date('Y-m-d H:', $ts) . str_pad($minute * $num, 2, '0', STR_PAD_LEFT); } } elseif ($unit == 'hour') { if ($num == 1) { $key = date('Y-m-d H:00', $ts); } else { $hour = floor(date('H', $ts) / $num);