public function index() { $this->articles = fRecordSet::build('Article', array('type=' => 'news', 'visible=' => 1), array('priority' => 'desc', 'created_at' => 'desc'), ACTIVITIES_LIMIT - 2); $this->posts = fRecordSet::build('Article', array('type=' => 'post', 'visible=' => 1, 'priority<' => 999999), array('priority' => 'desc', 'created_at' => 'desc'), ACTIVITIES_LIMIT - 1); $this->activities = fRecordSet::buildFromSQL('Activity', 'SELECT activities.* FROM activities GROUP BY realname,type,DATE(timestamp),HOUR(timestamp) ORDER BY timestamp DESC LIMIT ' . ACTIVITIES_LIMIT); $this->render('home/index'); }
/** * Returns all active checks on the system * * @param string $sort_column The column to sort by * @param string $sort_dir The direction to sort the column * @return fRecordSet An object containing all meetups */ static function findActive() { return fRecordSet::buildFromSQL( __CLASS__, array("SELECT checks.* FROM checks JOIN subscriptions ON checks.check_id = subscriptions.check_id WHERE enabled = 1;") ); }
public static function findByBranch($branch, $doctype) { //return fRecordSet::buildFromSQL('Production_issue', // "SELECT production_issues.* FROM production_issues, (SELECT * FROM users WHERE branch_id = '$branch') AS tbl WHERE production_issues.issuer = tbl.username AND production_issues.doc_type = '$doctype' AND YEAR( production_issues.doc_date ) = YEAR( CURDATE( ) ) AND MONTH( production_issues.doc_date ) = MONTH( CURDATE( ))", // "SELECT count(*) FROM production_issues" // ); return fRecordSet::buildFromSQL('Production_issue', "SELECT production_issues.* FROM production_issues WHERE production_issues.doc_number LIKE '" . $doctype . "/" . $branch . "/" . "%" . "' AND YEAR( production_issues.doc_date ) = YEAR( CURDATE( ) ) AND MONTH( production_issues.doc_date ) = MONTH( CURDATE( ) )", "SELECT count(*) FROM production_issues"); }
static function findActive($check_id = NULL) { if (!is_null($check_id) && is_numeric($check_id)) { $filter = ' AND check_id=' . $check_id; } else { $filter = ''; } return fRecordSet::buildFromSQL(__CLASS__, array('SELECT subscriptions.* FROM subscriptions WHERE user_id = ' . fSession::get('user_id') . $filter)); }
static function findPOByBranch($branch, $doctype) { return fRecordSet::buildFromSQL('Purchase', "SELECT purchases.* FROM purchases WHERE purchases.po_number LIKE '" . "PO" . $doctype . "/" . $branch . "/" . "%" . "' AND YEAR( purchases.doc_date ) = YEAR( CURDATE( ) ) AND MONTH( purchases.doc_date ) = MONTH( CURDATE( ) )", "SELECT count(*) FROM purchases"); /* return fRecordSet::buildFromSQL('Purchase', "SELECT purchases.* FROM purchases, (SELECT * FROM users WHERE branch_id = '$branch') AS tbl WHERE purchases.requester = tbl.username AND purchases.doc_tag = 'po' AND purchases.doc_type = '$doctype' AND YEAR( purchases.po_date ) = YEAR( CURDATE( ) ) AND MONTH( purchases.po_date ) = MONTH( CURDATE( ) )", "SELECT count(*) FROM purchases" ); */ }
static function findCurrentMonth($month, $year) { return fRecordSet::buildFromSQL('Currency', "SELECT currencies.* FROM currencies WHERE YEAR(month) = {$year} AND MONTH(month) = {$month}"); }
public static function getByRoleAndEmail($id_role, $email, $region) { $region = implode(",", $region); return fRecordSet::buildFromSQL(__CLASS__, "SELECT * FROM user WHERE id_role = {$id_role} AND id_user IN (SELECT id_user FROM userregion WHERE id_region IN ({$region}))"); }
public function testBuildFromSQLNonLimitedCount() { $set = fRecordSet::buildFromSQL('User', sprintf("SELECT %s.* FROM %s LIMIT 2", fORM::tablize('User'), fORM::tablize('User')), sprintf("SELECT count(*) FROM %s", fORM::tablize('User'))); $this->assertEquals(array(1, 2), $set->getPrimaryKeys()); $this->assertEquals(4, $set->count(TRUE)); }
<?php $typeOfUser = fAuthorization::checkAuthLevel('super'); //$canEdit = fAuthorization::checkACL('poll', 'edit'); //$canDelete = fAuthorization::checkACL('poll', 'delete'); $where = ""; if (!$typeOfUser) { $where = " WHERE " . fSession::get('where_at'); } $limit = fRequest::encode('limit', 'integer'); $page = fRequest::encode('p', 'integer'); if ($page < 1) { exit; } $start = ($page - 1) * $limit; $sections = fRecordSet::buildFromSQL('BannerSection', "SELECT * FROM bannersection {$where} LIMIT {$start},{$limit}", "SELECT count(*) FROM bannersection {$where}", $limit, $page); if ($sections->count() == 0) { echo '<div class="notification information" > Por el momento no hay registros en <b> Secciones de banners </b>. </div>'; } else { $p = new Pagination($sections->getPages(), $sections->getPage(), 3); $pagination = $p->getPaginationLinks(); ?> <center> <table class="contenttoc" style="width:auto; float:left"> <tr> <th> <input type="checkbox" name="check" id="check" /> </th> <th> Nombre </th> <th> Editar </th> <th> Eliminar </th>
static function findCurrentMonth($branch) { return fRecordSet::buildFromSQL('Good_receipt_note', "SELECT good_receipt_notes.* FROM good_receipt_notes WHERE good_receipt_notes.branch_id = '{$branch}' AND good_receipt_notes.doc_type = 'GRN' AND YEAR( good_receipt_notes.doc_date ) = YEAR( CURDATE( )) AND MONTH( good_receipt_notes.doc_date ) = MONTH( CURDATE( ))", "SELECT count(*) FROM good_receipt_notes"); }
static public function findUsersResults() { return fRecordSet::buildFromSQL( __CLASS__, array('SELECT check_results.* FROM check_results JOIN subscriptions ON check_results.check_id = subscriptions.check_id and subscriptions.user_id = ' . fSession::get('user_id'))); }
$where = " WHERE " . fSession::get('where_at') . " AND "; } $section = 'geolocation'; $section_id = 25; $sub = 'list'; ?> <?php $query = fRequest::encode('query', 'string'); $limit = fRequest::encode('limit', 'integer'); $page = fRequest::encode('p', 'integer'); if ($page < 1) { exit; } $start = ($page - 1) * $limit; $av = fRecordSet::buildFromSQL('EconomicUnit', "SELECT * FROM economic_units {$where} ( economic_unit_name LIKE '%{$query}%' OR economic_unit_street_type LIKE '%{$query}%' OR economic_unit_street_name LIKE '%{$query}%' OR economic_unit_phone LIKE '%{$query}%' OR economic_unit_region IN (SELECT id_region FROM region WHERE name LIKE '%{$query}%')) LIMIT {$start},{$limit}", "SELECT count(*) FROM economic_units {$where} ( economic_unit_name LIKE '%{$query}%' OR economic_unit_street_type LIKE '%{$query}%' OR economic_unit_street_name LIKE '%{$query}%' OR economic_unit_phone LIKE '%{$query}%' OR economic_unit_region IN (SELECT id_region FROM region WHERE name LIKE '%{$query}%'))", $limit, $page); if ($av->count() == 0) { echo '<div class="notification information" > Por el momento no hay registros en <b> Observatorio </b>. </div>'; } else { $p = new Pagination($av->getPages(), $av->getPage(), 3); $pagination = $p->getPaginationLinks(); ?> <center> <table class="contenttoc" style="width:auto; float:none"> <tr> <th> <input type="checkbox" name="check" id="check" /> </th> <th> Nombre </th>
<?php define('MY_ROOT', realpath(dirname(__FILE__) . '/../')); include MY_ROOT . '/inc/init.php'; include MY_ROOT . '/inc/flourishDB.php'; $output = file_get_contents("daiichi-mp-May-j.csv"); $lines = preg_split('/[\\n\\r]+/', $output); $headerLine = array_shift($lines); //waste the header $headerLine = array_shift($lines); //there are two lines of header $lastInserts = fRecordSet::buildFromSQL('Fukushimadata', "SELECT * FROM `fukushimadatas` \nWHERE `station_id` IN (800,801,802,803,804,805,806,807)\nORDER BY `reading_date` DESC \nLIMIT 1"); $lastDate = $lastInserts[0]->getReadingDate(); print_r($lastInserts); print_r($lastDate); foreach ($lines as $line) { $columns = explode(",", $line); $date = str_replace("/", "-", $columns[0]); $time = $columns[1]; $datetime = $date . " " . $time . ":00"; $timestamp = new fTimestamp($datetime); print_r($timestamp); if ($lastDate->gte($timestamp)) { echo "skipping row <br />"; continue; } echo "successfull Row \n\r"; if ($columns[2] != "" && $columns[2] != "N/A") { try { $reading = new Fukushimadata(); $reading->setReadingDate($datetime);
<?php $limit = fRequest::encode('limit', 'integer'); $page = fRequest::encode('p', 'integer'); if ($page < 1) { exit; } $start = ($page - 1) * $limit; $typeOfUser = fAuthorization::checkAuthLevel('super'); $where = ""; $users = fRecordSet::buildFromSQL('User', "SELECT * FROM " . TBL_USER . " {$where} LIMIT {$start},{$limit}", "SELECT count(*) FROM " . TBL_USER . " {$where}", $limit, $page); if ($users->count() == 0) { echo '<div class="notification information" > Por el momento no hay registros en <b> Usuarios </b> </div>'; } else { $p = new Pagination($users->getPages(), $users->getPage(), 3); $pagination = $p->getPaginationLinks(); ?> <center> <table class="contenttoc" style="width:100%;float:none"> <tr> <th><input type="checkbox" id="check" /></th> <th>Email</th> <th>Rol</th> <th>Nombre</th> <th>Apellidos</th> <th>Fecha Nacimiento</th> <th>Teléfono</th> <th>Celular</th> <th>Nextel</th>
/** * @param integer $respondentId * @param array $orderBy * @return WpTesting_Model_Test[] */ public function findAllByPassingRespondent($respondentId, array $orderBy = array('Test.ID')) { return fRecordSet::buildFromSQL($this->modelName, array(implode(PHP_EOL, array('SELECT DISTINCT Test.* FROM %r AS Test', 'JOIN %r AS Passing ON Passing.test_id = Test.ID AND Passing.respondent_id = %i', 'WHERE Test.post_type = %s', 'ORDER BY %s')), array($this->tableName, fORM::tablize('WpTesting_Model_Passing'), $respondentId, 'wpt_test', implode(',', $orderBy)))); }
<?php include './inc/init.php'; include './inc/flourishDB.php'; $users = fRecordSet::build('User'); $submissions = fRecordSet::build('Reading'); $totalSubmissions = $submissions->count(); $totalSubmissions -= 610; $japanSubmissions = fRecordSet::buildFromSQL('Reading', "SELECT * FROM `readings` WHERE `lat` > 33.267 AND `lat` < 43.3098 AND `lng` > 130.41 AND `lng` < 141.9236"); $tmpl->set('title', 'Stats'); $tmpl->set('siteName', $translations->siteName); $tmpl->set('siteTagline', $translations->siteTagline); $tmpl->set('formallyKnownAs', $translations->formallyKnownAs); $tmpl->set('maps', $translations->maps); $tmpl->set('blog', $translations->blog); $tmpl->set('forums', $translations->forums); $tmpl->set('submitAReading', $translations->submitAReading); $tmpl->set('languageSelect', $translations->languageSelect); $tmpl->set('contact', $translations->contact); $tmpl->set('follow', $translations->follow); $tmpl->set('termsPolicy', $translations->termsPolicy); $tmpl->set('pageName', 'stats'); $tmpl->set('lang', $lang); $tmpl->place('header'); ?> <div class="content"> <div class="relativeWrap"> <div class="twoColumnWidth"> <div id="map_canvas"> <h1><b><?php
public function testBuildFromSQL() { $set = fRecordSet::buildFromSQL('Flourish2User', fix_schema("SELECT * FROM flourish2.users")); $this->assertEquals(array(1, 2), $set->getPrimaryKeys()); }
$typeOfUser = fAuthorization::checkAuthLevel('super'); $where = " WHERE "; if (!$typeOfUser) { $where = " WHERE " . fSession::get('where_at'); } ?> <?php $limit = fRequest::encode('limit', 'integer'); $page = fRequest::encode('p', 'integer'); $query = fRequest::encode('query', 'string'); if ($page < 1) { exit; } $start = ($page - 1) * $limit; $categories = fRecordSet::buildFromSQL('EconomicUnitCategory', "SELECT * FROM economic_unit_categories {$where} (economic_unit_category_name LIKE '%{$query}%' OR economic_unit_category_region IN (SELECT id_region FROM region WHERE name LIKE '%{$query}%')) LIMIT {$start},{$limit}", "SELECT count(*) FROM economic_unit_categories {$where} (economic_unit_category_name LIKE '%{$query}%' OR economic_unit_category_region IN (SELECT id_region FROM region WHERE name LIKE '%{$query}%'))", $limit, $page); if ($categories->count() == 0) { echo '<div class="notification information" > Por el momento no hay registros en <b> Categorías de Geolocalización</b>. </div>'; } else { $p = new Pagination($categories->getPages(), $categories->getPage(), 3); $pagination = $p->getPaginationLinks(); ?> <center> <table class="contenttoc" style="width:auto; float:left"> <tr> <th> <input type="checkbox" name="check" id="check" /> </th> <th> Nombre </th> <th> Editar </th> <th> Eliminar </th>
static function findAllLimit($first = 0, $number = 500) { return fRecordSet::buildFromSQL('Inv_item', "SELECT * FROM inv_items ORDER BY `id` ASC LIMIT {$first} , {$number}", "SELECT count(*) FROM inv_items"); }
$typeOfUser = fAuthorization::checkAuthLevel('super'); $where = " WHERE "; if (!$typeOfUser) { $where = " WHERE " . fSession::get('where_at') . " AND "; } ?> <?php $limit = fRequest::encode('limit', 'integer'); $page = fRequest::encode('p', 'integer'); $query = fRequest::encode('query', 'string'); if ($page < 1) { exit; } $start = ($page - 1) * $limit; $categories = fRecordSet::buildFromSQL('category', "SELECT * FROM category {$where} (name LIKE '%{$query}%') LIMIT {$start},{$limit}", "SELECT count(*) FROM category {$where} (name LIKE '%{$query}%')", $limit, $page); $p = new Pagination($categories->getPages(), $categories->getPage(), 3); $pagination = $p->getPaginationLinks(); ?> <center> <table class="contenttoc" style="width:auto; float:left"> <tr> <th> <input type="checkbox" name="check" id="check" /> </th> <th> Nombre </th> <th> Editar </th> <th> Eliminar </th> </tr> <?php date_default_timezone_set('America/Mexico_City'); foreach ($categories as $category) {
<?php define('MY_ROOT', realpath(dirname(__FILE__) . '/../')); include MY_ROOT . '/inc/init.php'; include MY_ROOT . '/inc/flourishDB.php'; //$stations = fRecordSet::build('Station', NULL, NULL, 100, 100); $stations = fRecordSet::buildFromSQL('Station', "SELECT * FROM stations"); $output = '{"results":['; $datastreams = ""; $jsonData = ""; foreach ($stations as $station) { //$stationdatas = $station->buildStationdatas(); $stationdatas = fRecordSet::buildFromSQL('Stationdata', array("SELECT * FROM `stationdatas` WHERE `station_id`=%i ORDER BY `reading_date` DESC LIMIT 0 , 6", $station->getStationId())); //$stationdatas->sort('getDatetimeString','desc'); $datastreams .= '{"title": "' . $station->getStationName2En() . '",' . '"title_jp": "' . $station->getStationName2Jp() . '",' . '"description": "",' . '"creator": "mext",' . '"feed": "http://www.rdtn.org/feeds/station/' . $station->getStationId() . '.json",' . '"location": {"lon":' . $station->getLongitude() . ', "lat":' . $station->getLatitude() . ', "name": "' . $station->getPrefectureNameEn() . '"},' . '"id":' . $station->getStationId() . ',' . '"datastreams": ['; $success = false; foreach ($stationdatas as $stationdata) { $sa = $stationdata->getSa(); if ($sa != -888 && $sa != -999) { $datastreams .= '{"at": "' . $stationdata->getReadingDate() . '",' . '"max_value": "' . $stationdata->getRa() . '",' . '"min_value": "' . $stationdata->getRa() . '",' . '"current_value": "' . $stationdata->getSa() . '",' . '"id": "' . $stationdata->getReadingId() . '",' . '"unit": {"type": "basicSI","label": "nano Gray per hour","symbol": "nGy/h"}}'; $success = true; break; } } if ($success) { //close and append $datastreams .= ']},'; $jsonData .= $datastreams; } $datastreams = ""; }
<?php fSession::open(); $idUser = fSession::get(SESSION_ID_USER); if (empty($idUser)) { header('Location: ' . SITE); exit("No se ha podido acceder a esta secci&oacite;n"); } //if (fRequest::isPost()): $section_id = fRequest::encode('id_section', 'integer'); $parent_id = fRequest::encode('id_parent', 'integer'); //var_dump($_POST); var_dump($_GET); //$categories = Category::findAllUp($section_id,0,$region_id); $categories = fRecordSet::buildFromSQL("Category", "SELECT * FROM category WHERE id_section = {$section_id} AND id_parent = {$parent_id}"); ?> <?php if ($categories->count() > 0) { echo '<tr> <td><label for="id_category"> Categoría </label> </td> <td > <select class="subcategories" style="width:680px; " name="id_category">'; foreach ($categories as $category) { echo '<option value="' . $category->prepareId_category() . '"> ' . $category->prepareName() . ' </option>'; } //endif; ?> </select> </td> </tr> <tr class="category_select">
<?php define('MY_ROOT', realpath(dirname(__FILE__) . '/../')); include MY_ROOT . '/inc/init.php'; include MY_ROOT . '/inc/flourishDB.php'; //$stations = fRecordSet::build('Station', NULL, NULL, 100, 100); $stations = fRecordSet::buildFromSQL('Station', "SELECT * FROM stations WHERE `source` IN ('fukushima_fleep','fukushima_daiichi')"); $output = '{"results":['; $datastreams = ""; $jsonData = ""; foreach ($stations as $station) { //$stationdatas = $station->buildStationdatas(); $fleepdatas = fRecordSet::buildFromSQL('Fleepdata', array("SELECT * FROM `fukushimadatas` WHERE `station_id`=%i AND reading_date > ADDDATE(NOW(), INTERVAL -9 DAY) ORDER BY `reading_date` DESC LIMIT 0 , 6", $station->getStationId())); //$fleepdatas = fRecordSet::buildFromSQL('Fleepdata', array("SELECT * FROM `fukushimadatas` WHERE `station_id`=%i ORDER BY `reading_date` DESC LIMIT 0 , 6",$station->getStationId())); //$stationdatas->sort('getDatetimeString','desc'); $datastreams .= '{"title": "' . $station->getStationNameEn() . '",' . '"title_jp": "' . $station->getStationNameJp() . '",' . '"description": "",' . '"creator": "fukushima_fleep",' . '"feed": "http://www.rdtn.org/feeds/station/' . $station->getStationId() . '.json",' . '"location": {"lon":' . $station->getLongitude() . ', "lat":' . $station->getLatitude() . ', "name": "' . $station->getPrefectureNameEn() . '"},' . '"id":' . $station->getStationId() . ',' . '"datastreams": ['; $success = false; foreach ($fleepdatas as $fleepdata) { $sa = $fleepdata->getReadingValue(); if ($sa != -888 && $sa != -999) { $unit = $fleepdata->createUnit(); $datastreams .= '{"at": "' . $fleepdata->getReadingDate() . '",' . '"max_value": "0",' . '"min_value": "0",' . '"current_value": "' . $fleepdata->getReadingValue() . '",' . '"id": "' . $fleepdata->getReadingId() . '",' . '"unit": {"type": "basicSI","label": "' . $unit->getUnitLabel() . '","symbol": "' . $unit->getUnitSymbol() . '"}}'; $success = true; break; } } if ($success) { //close and append $datastreams .= ']},'; $jsonData .= $datastreams; }
static function findByBranchLimit($key, $first = 0, $number = 500) { return fRecordSet::buildFromSQL('Inv_stock', "SELECT * FROM inv_stocks WHERE `branch_id` = '{$key}' ORDER BY `item_id` ASC LIMIT {$first} , {$number}", "SELECT count(*) FROM inv_stocks WHERE `branch_id` = '{$key}'"); }
<?php $typeOfUser = fAuthorization::checkAuthLevel('super'); //$canEdit = fAuthorization::checkACL('poll', 'edit'); //$canDelete = fAuthorization::checkACL('poll', 'delete'); $where = " WHERE "; if (!$typeOfUser) { $where = " WHERE " . fSession::get('where_at') . " AND "; } $limit = fRequest::encode('limit', 'integer'); $page = fRequest::encode('p', 'integer'); $query = fRequest::encode('query', 'string'); if ($page < 1) { exit; } $start = ($page - 1) * $limit; $sections = fRecordSet::buildFromSQL('BannerSection', "SELECT * FROM bannersection {$where} (name LIKE '%{$query}%' OR id_region IN (SELECT id_region FROM region WHERE name LIKE '%{$query}%')) LIMIT {$start},{$limit}", "SELECT count(*) FROM bannersection {$where} (name LIKE '%{$query}%' OR id_region IN (SELECT id_region FROM region WHERE name LIKE '%{$query}%'))", $limit, $page); if ($sections->count() == 0) { echo '<div class="notification information" > Por el momento no hay registros en <b> Secciones de banners </b>. </div>'; } else { $p = new Pagination($sections->getPages(), $sections->getPage(), 3); $pagination = $p->getPaginationLinks(); ?> <center> <table class="contenttoc" style="width:auto; float:left"> <tr> <th> <input type="checkbox" name="check" id="check" /> </th> <th> Nombre </th> <th> Editar </th> <th> Eliminar </th>
<?php fSession::open(); $idUser = fSession::get(SESSION_ID_USER); if (empty($idUser)) { header('Location: ' . SITE); exit("No se ha podido acceder a esta sección"); } $where = " WHERE id_parent = 0 "; $sections = fRecordSet::buildFromSQL('BannerSection', "SELECT * FROM bannersection {$where}"); if ($sections->count() > 0) { foreach ($sections as $section) { echo '<option value="' . $section->prepareIdBannersection() . '">' . $section->prepareName() . '</option>'; } } else { echo '<option value="0">No hay Secciones</option>'; }
$sub = 'listGcategory'; $typeOfUser = fAuthorization::checkAuthLevel('super'); $where = ""; if (!$typeOfUser) { $where = " WHERE " . fSession::get('where_at'); } ?> <?php $limit = fRequest::encode('limit', 'integer'); $page = fRequest::encode('p', 'integer'); if ($page < 1) { exit; } $start = ($page - 1) * $limit; $categories = fRecordSet::buildFromSQL('EconomicUnitCategory', "SELECT * FROM economic_unit_categories {$where} LIMIT {$start},{$limit}", "SELECT count(*) FROM economic_unit_categories {$where}", $limit, $page); if ($categories->count() == 0) { echo '<div class="notification information" > Por el momento no hay registros en <b> Categorías de Geolocalización</b>. </div>'; } else { $p = new Pagination($categories->getPages(), $categories->getPage(), 3); $pagination = $p->getPaginationLinks(); ?> <center> <table class="contenttoc" style="width:auto; float:left"> <tr> <th> <input type="checkbox" name="check" id="check" /> </th> <th> Nombre </th> <th> Editar </th> <th> Eliminar </th>
<?php define('MY_ROOT', realpath(dirname(__FILE__) . '/../')); include MY_ROOT . '/inc/init.php'; include MY_ROOT . '/inc/flourishDB.php'; //$stations = fRecordSet::build('Station', NULL, NULL, 100, 100); $stationdatas = fRecordSet::buildFromSQL('Greenpeacedata', "SELECT * FROM greenpeacedatas WHERE reading_date > ADDDATE(NOW(), INTERVAL -2 DAY)"); $output = '{"results":['; $datastreams = ""; $jsonData = ""; foreach ($stationdatas as $stationdata) { $datastreams .= '{"title": "Greenpeace Reading",' . '"title_jp": "Greenpeace Reading",' . '"description": "",' . '"creator": "greenpeace",' . '"feed": "",' . '"location": {"lon":' . $stationdata->getLongitude() . ', "lat":' . $stationdata->getLatitude() . ', "name": "' . $stationdata->getComments() . '"},' . '"id":"",' . '"datastreams": ['; $success = false; $datastreams .= '{"at": "' . $stationdata->getReadingDate() . '",' . '"max_value": "' . $stationdata->getMicrosieverts() . '",' . '"min_value": "' . $stationdata->getMicrosieverts() . '",' . '"current_value": "' . $stationdata->getMicrosieverts() . '",' . '"id": "' . $stationdata->getId() . '",' . '"unit": {"type": "basicSI","label": "microsieverts per hour","symbol": "μSv/h"}}'; $success = true; if ($success) { //close and append $datastreams .= ']},'; $jsonData .= $datastreams; } $datastreams = ""; } $output .= rtrim($jsonData, ','); $output .= '], "itemsPerPage": ' . $stationdatas->count() . ', "startIndex": 0, "totalResults": ' . $stationdatas->count(TRUE) . '}'; $file = new fFile(DOC_ROOT . '/feeds/greenpeaceStatic.json'); $file->write($output); echo $output; ?>
public function testBuildFromSQL() { $set = fRecordSet::buildFromSQL('Db2User', "SELECT * FROM users ORDER BY user_id ASC"); $this->assertEquals(array(1, 2), $set->getPrimaryKeys()); }
static function findByBranchToFro($branch, $limit = null) { return fRecordSet::buildFromSQL('Material_transfer', "SELECT material_transfers.* FROM material_transfers WHERE `status` = 'pending' AND (`branch_to` = '{$branch}' OR `branch_from` = '{$branch}')", "SELECT count(*) FROM material_transfers"); }