Ejemplo n.º 1
0
        $in_sql = "Insert Into `{$tb}`({$key}) Value ({$var});";
        $sth = $this->db->prepare($in_sql);
        $sth->execute(array_values($data));
        return $this->db->lastInsertId();
    }
    /**
     * 返回一行数据
     * @param 
     */
    protected function FetchRow($sql)
    {
        $p = $this->db->query($sql);
        $p->setFetchMode(PDO::FETCH_ASSOC);
        $result = $p->fetchAll();
        return $result[0];
    }
    protected function Execute($sql, $data)
    {
        $dbd = $this->db->prepare($sql);
        return $dbd->execute($data);
    }
}
$obj = new AcLog();
$stations = $obj->STATIONS;
foreach ($stations as $key => $var) {
    $obj->setPath($var['name']);
    $stationnum = $obj->samestationnum($var['name']);
    $obj->ac($var['num'], $var['ap'], $var['is_alone'], $var['acip'], $stationnum, $var['name']);
}
//$obj->Ex_Qufu();
echo 'success';
Ejemplo n.º 2
0
function execsql($sdate, $edate)
{
    $hours = array('00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23');
    $sdate = strtotime($sdate);
    $edate = strtotime($edate);
    while ($sdate <= $edate) {
        $date = date('Y-m-d', $sdate);
        foreach ($hours as $hour) {
            $data = $date . '-' . $hour;
            $day = date('d', strtotime($date));
            $obj = new AcLog($hour, $data, $date, $day);
            $stations = $obj->STATIONS;
            foreach ($stations as $key => $var) {
                $obj->setPath($var['name']);
                $stationnum = $obj->samestationnum($var['name']);
                $obj->ac($var['num'], $var['ap'], $var['is_alone'], $var['acip'], $stationnum, $var['name']);
            }
        }
        $sdate = strtotime('+1 day', $sdate);
    }
}