本文整理汇总了PHP中R::getAll方法的典型用法代码示例。如果您正苦于以下问题:PHP R::getAll方法的具体用法?PHP R::getAll怎么用?PHP R::getAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类R
的用法示例。
在下文中一共展示了R::getAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getData
/**
* Runs a query to get all the dates for meetings based on SearchAttributeData. Then the data is processed
* and @returns a data array of dates and quantity. Quantity stands for how many meetings in a given date.
* (non-PHPdoc)
* @see CalendarDataProvider::getData()
*/
public function getData()
{
$sql = $this->makeSqlQuery();
$rows = R::getAll($sql);
$data = array();
foreach ($rows as $row) {
$localTimeZoneAdjustedDate = DateTimeUtil::convertDbFormattedDateTimeToLocaleFormattedDisplay($row['startdatetime'], 'medium', null);
if (isset($data[$localTimeZoneAdjustedDate])) {
$data[$localTimeZoneAdjustedDate]['quantity'] = $data[$localTimeZoneAdjustedDate]['quantity'] + 1;
} else {
$data[$localTimeZoneAdjustedDate] = array('date' => $localTimeZoneAdjustedDate, 'quantity' => 1, 'dbDate' => $row['startdatetime']);
}
}
foreach ($data as $key => $item) {
if ($item['quantity'] == 1) {
$label = Zurmo::t('MeetingsModule', '{quantity} MeetingsModuleSingularLabel', array_merge(LabelUtil::getTranslationParamsForAllModules(), array('{quantity}' => $item['quantity'])));
} else {
$label = Zurmo::t('MeetingsModule', '{quantity} MeetingsModulePluralLabel', array_merge(LabelUtil::getTranslationParamsForAllModules(), array('{quantity}' => $item['quantity'])));
}
$data[$key]['label'] = $label;
if ($item['quantity'] > 5) {
$quantityClassSuffix = 6;
} else {
$quantityClassSuffix = $item['quantity'];
}
$data[$key]['className'] = 'calendar-events-' . $quantityClassSuffix;
}
return $data;
}
示例2: getSubscribers
function getSubscribers($id)
{
$subs = R::getAll("select * from subscription where category_id='{$id}'");
if ($subs) {
return $subs;
}
}
示例3: get_Upload_details
public function get_Upload_details($last_upl)
{
/*
$user_delimiter =$this->sql_user_delimiter(0,0);
$sql = "SELECT
`pima_upload_id`,
`upload_date`,
`equipment_serial_number`,
`facility_name`,
`uploader_name`,
COUNT(`pima_test_id`) AS `total_tests`,
SUM(CASE WHEN `valid`= '1' THEN 1 ELSE 0 END) AS `valid_tests`,
SUM(CASE WHEN `valid`= '0' THEN 1 ELSE 0 END) AS `errors`,
SUM(CASE WHEN `valid`= '1' AND `cd4_count` < 350 THEN 1 ELSE 0 END) AS `failed`,
SUM(CASE WHEN `valid`= '1' AND `cd4_count` >= 350 THEN 1 ELSE 0 END) AS `passed`
FROM `v_pima_uploads_details`
WHERE 1
AND `pima_upload_id` > $last_upl
$user_delimiter
GROUP BY `pima_upload_id`
ORDER BY `upload_date` DESC
";
*/
$sql = "CALL get_last_upload_details(" . $last_upl . ")";
return $res = R::getAll($sql);
}
示例4: printLogs
public function printLogs()
{
$db_query = "SELECT * FROM (\r\n SELECT ttylog.session, timestamp, ROUND(LENGTH(ttylog)/1024, 2) AS size\r\n FROM ttylog\r\n JOIN auth ON ttylog.session = auth.session\r\n WHERE auth.success = 1\r\n GROUP BY ttylog.session\r\n ORDER BY timestamp DESC\r\n ) s\r\n WHERE size > " . PLAYBACK_SIZE_IGNORE;
$rows = R::getAll($db_query);
if (count($rows)) {
//We create a skeleton for the table
$counter = 1;
echo '<p>The following table displays a list of all the logs recorded by Kippo.
Click on column heads to sort data.</p>';
echo '<table id="Playlog-List" class="tablesorter"><thead>';
echo '<tr class="dark">';
echo '<th>ID</th>';
echo '<th>Timestamp</th>';
echo '<th>Size</th>';
echo '<th>Play the log</th>';
echo '</tr></thead><tbody>';
//For every row returned from the database we create a new table row with the data as columns
foreach ($rows as $row) {
echo '<tr class="light word-break">';
echo '<td>' . $counter . '</td>';
echo '<td>' . $row['timestamp'] . '</td>';
echo '<td>' . $row['size'] . 'kb' . '</td>';
echo '<td><a href="include/play.php?f=' . $row['session'] . '" target="_blank"><img class="icon" src="images/play.ico"/>Play</a></td>';
echo '</tr>';
$counter++;
}
//Close tbody and table element, it's ready.
echo '</tbody></table>';
echo '<hr /><br />';
}
}
示例5: testForeignKeysWithSQLite
/**
* Test foreign keys with SQLite.
*
* @return void
*/
public function testForeignKeysWithSQLite()
{
$book = R::dispense('book');
$page = R::dispense('page');
$cover = R::dispense('cover');
list($g1, $g2) = R::dispense('genre', 2);
$g1->name = '1';
$g2->name = '2';
$book->ownPage = array($page);
$book->cover = $cover;
$book->sharedGenre = array($g1, $g2);
R::store($book);
$fkbook = R::getAll('pragma foreign_key_list(book)');
$fkgenre = R::getAll('pragma foreign_key_list(book_genre)');
$fkpage = R::getAll('pragma foreign_key_list(page)');
asrt($fkpage[0]['from'], 'book_id');
asrt($fkpage[0]['to'], 'id');
asrt($fkpage[0]['table'], 'book');
asrt(count($fkgenre), 2);
if ($fkgenre[0]['from'] == 'book') {
asrt($fkgenre[0]['to'], 'id');
asrt($fkgenre[0]['table'], 'book');
}
if ($fkgenre[0]['from'] == 'genre') {
asrt($fkgenre[0]['to'], 'id');
asrt($fkgenre[0]['table'], 'genre');
}
asrt($fkbook[0]['from'], 'cover_id');
asrt($fkbook[0]['to'], 'id');
asrt($fkbook[0]['table'], 'cover');
}
示例6: update_facilities
public function update_facilities($id)
{
$sql = "SELECT \n\t\t\t\t\t `facility_id`,\n\t\t\t\t\t `equipment_id`,\n `serial_number`,\n `ctc_id_no`\n\t\t\t\tFROM `facility_equipment_request`\n\t\t\t\tWHERE id = {$id}";
$facilty = R::getAll($sql);
//print_r($facilty); die();
/*foreach ($facilty as $key => $val) {
$db = $val;
$tumepata = implode(',', $db);
echo $tumepata;
}
die;*/
if ($facilty[0]['equipment_id'] == 4) {
$facility_equipment_registration = array('id' => NULL, 'facility_id' => $facilty[0]['facility_id'], 'equipment_id' => $facilty[0]['equipment_id'], 'status' => '1', 'deactivation_reason' => ' ', 'date_added' => NULL, 'date_removed' => NULL, 'serial_number' => $facilty[0]['serial_number']);
$insert = $this->db->insert('facility_equipment', $facility_equipment_registration);
$asus = $this->db->insert_id();
$facility_registration = array('id' => NULL, 'facility_equipment_id' => $asus, 'serial_num' => $facilty[0]['serial_number'], 'ctc_id_no' => $facilty[0]['ctc_id_no']);
//print_r($facility_registration);die;
$insert = $this->db->insert('facility_pima', $facility_registration);
// $asus = $this->db->insert_id();
// $faciility_pima_id = array(
// 'facility_equipment_id' => $asus
// );
// $this->db->where('id', $asus);
// $this->db->update('facility_pima', $faciility_pima_id);
//print_r($asus); die();
return $insert;
} else {
$facility_registration = array('id' => NULL, 'facility_id' => $facilty[0]['facility_id'], 'equipment_id' => $facilty[0]['equipment_id'], 'status' => '1', 'deactivation_reason' => '', 'date_added' => NULL, 'date_removed' => NULL, 'serial_number' => $facilty[0]['serial_number']);
$insert = $this->db->insert('facility_equipment', $facility_registration);
return $insert;
}
}
示例7: save_fac_equip
public function save_fac_equip()
{
$this->login_reroute(array(1, 2));
$cat = $this->input->post("cat");
$eq = (int) $this->input->post("eq");
$fac = (int) $this->input->post("fac");
$serial = $this->input->post("serial");
$ctc = $this->input->post("ctc");
$last_eq_auto_id_res = R::getAll("SELECT `id` FROM `facility_equipment` ORDER BY `id` DESC LIMIT 1");
$next_eq_auto_id = 1;
if (sizeof($last_eq_auto_id_res) > 0) {
$next_eq_auto_id = $last_eq_auto_id_res[0]['id'] + 1;
} else {
$next_eq_auto_id = 1;
}
$this->db->trans_begin();
$this->db->query("INSERT INTO `facility_equipment` \n\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t`id`,\n\t\t\t\t\t\t\t\t\t`facility_id`,\n\t\t\t\t\t\t\t\t\t`equipment_id`,\n\t\t\t\t\t\t\t\t\t`serial_number`,\n\t\t\t\t\t\t\t\t\t`status`\n\t\t\t\t\t\t\t\t) \n\t\t\t\t\t\t\t\tVALUES(\n\t\t\t\t\t\t\t\t\t\t'{$next_eq_auto_id}',\n\t\t\t\t\t\t\t\t\t\t'{$fac}',\n\t\t\t\t\t\t\t\t\t\t'{$eq}',\n\t\t\t\t\t\t\t\t\t\t'{$serial}',\n\t\t\t\t\t\t\t\t\t\t'1'\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t");
if ($eq == 4) {
$this->db->query("INSERT INTO `facility_pima` \n\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t`facility_equipment_id`,\n\t\t\t\t\t\t\t\t\t\t`serial_num`,\n\t\t\t\t\t\t\t\t\t\t`ctc_id_no`\n\t\t\t\t\t\t\t\t\t) \n\t\t\t\t\t\t\t\t\tVALUES(\n\t\t\t\t\t\t\t\t\t\t\t'{$next_eq_auto_id}',\n\t\t\t\t\t\t\t\t\t\t\t'{$serial}',\n\t\t\t\t\t\t\t\t\t\t\t'{$ctc}'\n\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t");
}
if ($this->db->trans_status() === FALSE) {
$this->db->trans_rollback();
} else {
$this->db->trans_commit();
}
$this->home_page();
}
示例8: testFetchTypes
/**
* Tests the various ways to fetch (select queries)
* data using adapter methods in the facade.
* Also tests the new R::getAssocRow() method,
* as requested in issue #324.
*/
public function testFetchTypes()
{
R::nuke();
$page = R::dispense('page');
$page->a = 'a';
$page->b = 'b';
R::store($page);
$page = R::dispense('page');
$page->a = 'c';
$page->b = 'd';
R::store($page);
$expect = '[{"id":"1","a":"a","b":"b"},{"id":"2","a":"c","b":"d"}]';
asrt(json_encode(R::getAll('SELECT * FROM page')), $expect);
$expect = '{"1":"a","2":"c"}';
asrt(json_encode(R::getAssoc('SELECT id, a FROM page')), $expect);
asrt(json_encode(R::getAssoc('SELECT id, a, b FROM page')), $expect);
$expect = '[{"id":"1","a":"a"},{"id":"2","a":"c"}]';
asrt(json_encode(R::getAssocRow('SELECT id, a FROM page')), $expect);
$expect = '[{"id":"1","a":"a","b":"b"},{"id":"2","a":"c","b":"d"}]';
asrt(json_encode(R::getAssocRow('SELECT id, a, b FROM page')), $expect);
$expect = '{"id":"1","a":"a","b":"b"}';
asrt(json_encode(R::getRow('SELECT * FROM page WHERE id = 1')), $expect);
$expect = '"a"';
asrt(json_encode(R::getCell('SELECT a FROM page WHERE id = 1')), $expect);
$expect = '"b"';
asrt(json_encode(R::getCell('SELECT b FROM page WHERE id = 1')), $expect);
$expect = '"c"';
asrt(json_encode(R::getCell('SELECT a FROM page WHERE id = 2')), $expect);
$expect = '["a","c"]';
asrt(json_encode(R::getCol('SELECT a FROM page')), $expect);
$expect = '["b","d"]';
asrt(json_encode(R::getCol('SELECT b FROM page')), $expect);
}
示例9: update
public function update($id)
{
$request_fields = file_get_contents('php://input');
$report_type = json_decode($request_fields, true);
$rpt_updated = R::getAll("UPDATE `report_type` \n\t\t\t\t\t\t\t\tSET \n\t\t\t\t\t\t\t\t\t`report_name`='{$report_type['report_name']}',\n\t\t\t\t\t\t\t\t\t`description`='{$report_type['description']}'\n\t\t\t\t\t\t\t\tWHERE \n\t\t\t\t\t\t\t\t\t`id` = '{$id}'\n\t\t\t\t\t\t\t\t");
return $rpt_updated;
}
示例10: makeCombinedData
/**
* @return array
*/
protected function makeCombinedData()
{
$combinedRows = array();
$groupBy = $this->resolveGroupBy('EmailMessage', 'sentDateTime');
$beginDateTime = DateTimeUtil::convertDateIntoTimeZoneAdjustedDateTimeBeginningOfDay($this->beginDate);
$endDateTime = DateTimeUtil::convertDateIntoTimeZoneAdjustedDateTimeEndOfDay($this->endDate);
if ($this->marketingList == null) {
$searchAttributeData = static::makeCampaignsSearchAttributeData('sentDateTime', $beginDateTime, $endDateTime, $this->campaign);
$sql = static::makeCampaignsSqlQuery($searchAttributeData, $groupBy);
$rows = R::getAll($sql);
foreach ($rows as $row) {
$chartIndexToCompare = $row[$this->resolveIndexGroupByToUse()];
$combinedRows[$chartIndexToCompare] = $row;
}
}
if ($this->campaign == null) {
$searchAttributeData = static::makeAutorespondersSearchAttributeData('sentDateTime', $beginDateTime, $endDateTime, $this->marketingList);
$sql = static::makeAutorespondersSqlQuery($searchAttributeData, $groupBy);
$rows = R::getAll($sql);
foreach ($rows as $row) {
$chartIndexToCompare = $row[$this->resolveIndexGroupByToUse()];
if (!isset($combinedRows[$chartIndexToCompare])) {
$combinedRows[$chartIndexToCompare] = $row;
} else {
$combinedRows[$chartIndexToCompare][self::COUNT] += $row[self::COUNT];
$combinedRows[$chartIndexToCompare][self::UNIQUE_OPENS] += $row[self::UNIQUE_OPENS];
$combinedRows[$chartIndexToCompare][self::UNIQUE_CLICKS] += $row[self::UNIQUE_CLICKS];
}
}
}
return $combinedRows;
}
示例11: get_pima_controls_reported
public function get_pima_controls_reported($user_group_id, $user_filter_used, $from, $to)
{
$sql = "CALL get_pima_controls_reported('" . $from . "','" . $to . "'," . $user_group_id . "," . $user_filter_used . ")";
$res = R::getAll($sql);
// print_r($res);die();
return $res;
}
示例12: testProcessStatusAndMessagesForEachRow
public function testProcessStatusAndMessagesForEachRow()
{
Yii::app()->user->userModel = User::getByUsername('super');
$import = new Import();
$serializedData['importRulesType'] = 'ImportModelTestItem';
$import->serializedData = serialize($serializedData);
$this->assertTrue($import->save());
$testTableName = $import->getTempTableName();
$this->assertTrue(ImportTestHelper::createTempTableByFileNameAndTableName('importTest.csv', $testTableName));
$count = ImportDatabaseUtil::getCount($testTableName);
$this->assertEquals(5, $count);
//Now add import results.
$resultsUtil = new ImportResultsUtil($import);
$rowDataResultsUtil = new ImportRowDataResultsUtil(2);
$rowDataResultsUtil->setStatusToUpdated();
$rowDataResultsUtil->addMessage('the first message');
$resultsUtil->addRowDataResults($rowDataResultsUtil);
$rowDataResultsUtil = new ImportRowDataResultsUtil(3);
$rowDataResultsUtil->setStatusToCreated();
$rowDataResultsUtil->addMessage('the second message');
$resultsUtil->addRowDataResults($rowDataResultsUtil);
$rowDataResultsUtil = new ImportRowDataResultsUtil(4);
$rowDataResultsUtil->setStatusToError();
$rowDataResultsUtil->addMessage('the third message');
$resultsUtil->addRowDataResults($rowDataResultsUtil);
$resultsUtil->processStatusAndMessagesForEachRow();
$sql = 'select * from ' . $testTableName . ' where id != 1';
$tempTableData = R::getAll($sql);
$compareData = array(array('id' => 2, 'column_0' => 'abc', 'column_1' => '123', 'column_2' => 'a', 'status' => 1, 'serializedmessages' => serialize(array('the first message'))), array('id' => 3, 'column_0' => 'def', 'column_1' => '563', 'column_2' => 'b', 'status' => 2, 'serializedmessages' => serialize(array('the second message'))), array('id' => 4, 'column_0' => 'efg', 'column_1' => '456', 'column_2' => 'a', 'status' => 3, 'serializedmessages' => serialize(array('the third message'))), array('id' => 5, 'column_0' => 'we1s', 'column_1' => null, 'column_2' => 'b', 'status' => null, 'serializedmessages' => null));
$this->assertEquals($compareData, $tempTableData);
}
示例13: user_desc
public function user_desc($user_group_id, $user_filter_used)
{
$sql = "";
$display = "";
if ($user_filter_used > 0) {
if ($user_group_id == 3) {
$sql = "SELECT COUNT(*), `name` FROM `partner` WHERE `id`= {$user_filter_used} ";
$display = "Partner: ";
} elseif ($user_group_id == 9) {
$sql = "SELECT COUNT(*), `name` FROM `region` WHERE `id`= {$user_filter_used} ";
$display = "Region: ";
} elseif ($user_group_id == 8) {
$sql = "SELECT COUNT(*), `name` FROM `district` WHERE `id`= {$user_filter_used} ";
$display = "District: ";
} elseif ($user_group_id == 6) {
$sql = "SELECT COUNT(*), `name` FROM `facility` WHERE `id`= {$user_filter_used} ";
$display = "Facility: ";
}
}
if ($sql != "") {
$res = R::getAll($sql);
echo $display . $res[0]["name"];
} else {
echo "National";
}
}
示例14: read_ctrl
public function read_ctrl()
{
$sql_get_ctr = "SELECT * FROM `v_pima_tests_details` WHERE `assay_id`='3'";
$ctr_res = R::getAll($sql_get_ctr);
foreach ($ctr_res as $key => $value) {
$sql_ins = "INSERT INTO `pima_control` \n\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t`device_test_id`,\n\t\t\t\t\t\t\t\t\t`pima_upload_id`,\n\t\t\t\t\t\t\t\t\t`assay_id`,\n\t\t\t\t\t\t\t\t\t`sample_code`,\n\t\t\t\t\t\t\t\t\t`error_id`,\n\t\t\t\t\t\t\t\t\t`operator`,\n\t\t\t\t\t\t\t\t\t`barcode`,\n\t\t\t\t\t\t\t\t\t`expiry_date`,\n\t\t\t\t\t\t\t\t\t`device`,\n\t\t\t\t\t\t\t\t\t`software_version`,\n\t\t\t\t\t\t\t\t\t`cd4_count`,\n\t\t\t\t\t\t\t\t\t`facility_equipment_id`,\n\t\t\t\t\t\t\t\t\t`result_date`\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t\t(\n\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t";
}
}
示例15: getAll
public function getAll($isBean = false)
{
if ($isBean) {
return R::findAll('guest', 'ORDER BY modify_date DESC');
} else {
return R::getAll('SELECT * FROM guest ORDER BY modify_date DESC');
}
}