$this->rain_noah3[$i] = $row;
                        }
                    }
                }
                $i = $i + 1;
            }
        }
    }
    global $con;
    $con = mysqli_connect($host, $user, $pass, $db);
    if (mysqli_connect_errno()) {
        echo "Failed to connect to MySQL: " . mysqli_connect_error();
    }
    $query = "SELECT max_rain_2year, rain_noah, rain_noah2, rain_noah3 FROM site_rain_props WHERE LEFT(name,3) = '{$site}'";
    $result = mysqli_query($con, $query);
    $maxAndTables = mysqli_fetch_assoc($result);
    //var_dump($maxAndTables);
    $noahArray = ['rain_noah', 'rain_noah2', 'rain_noah3'];
    $rain_info = new Noah();
    //var_dump($noah);
    $rain_info->max_rain_2year = $maxAndTables['max_rain_2year'];
    foreach ($noahArray as $name) {
        $rain_info->getData($con, $name, $maxAndTables[$name], $start_date, $end_date, $limit);
    }
    //var_dump($rain_info);
    mysqli_close($con);
    //echo json_encode($rain_info);
    return json_encode($rain_info);
}
# Testing Area
# getRainfallNoah('agb', '2015-01-21', null, null, null, null, null, null);
示例#2
-1
文件: base.php 项目: sfp12/darwin
 public function before()
 {
     $this->_response = Noah::instance('Response');
     $this->_request = Noah::instance('Request');
     $this->_profiler = Noah::instance('Profiler');
     $this->_app = Noah::instance('App');
     $this->_validation = Noah::instance('Validation');
     if ($this->_app->controller != 'login') {
         if (!isset($_SESSION['userInfo'])) {
             $this->_response->redirect('http://' . $_SERVER['HTTP_HOST'] . '/login');
         }
     }
     require_once Noah::getVendorPath() . 'smarty/Smarty.class.php';
     $this->smarty = new Smarty();
     foreach ($this->_app->config('smarty') as $key => $val) {
         $key = 'set' . ucfirst($key);
         $this->smarty->{$key}($val);
     }
     $this->smarty->assign("currentC", $this->_app->controller);
     $this->smarty->assign("action", $this->_app->action);
     if (isset($_SESSION['userinfo'])) {
         $this->smarty->assign("adminUser", $_SESSION['userinfo']);
     }
 }