本文整理汇总了PHP中R::getRow方法的典型用法代码示例。如果您正苦于以下问题:PHP R::getRow方法的具体用法?PHP R::getRow怎么用?PHP R::getRow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类R
的用法示例。
在下文中一共展示了R::getRow方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRun
public function testRun()
{
//Create 2 jobLogs, and set one with a date over a week ago (8 days ago) for the endDateTime
$eightDaysAgoTimestamp = DateTimeUtil::convertTimestampToDbFormatDateTime(time() - 60 * 60 * 24 * 8);
$jobLog = new JobLog();
$jobLog->type = 'Monitor';
$jobLog->startDateTime = $eightDaysAgoTimestamp;
$jobLog->endDateTime = $eightDaysAgoTimestamp;
$jobLog->status = JobLog::STATUS_COMPLETE_WITHOUT_ERROR;
$jobLog->isProcessed = false;
$jobLog->save();
$jobLog2 = new JobLog();
$jobLog2->type = 'ImportCleanup';
$jobLog2->startDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime(time());
$jobLog2->endDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime(time());
$jobLog2->status = JobLog::STATUS_COMPLETE_WITHOUT_ERROR;
$jobLog2->isProcessed = false;
$jobLog2->save();
$sql = 'select count(*) count from item';
$row = R::getRow($sql);
$this->assertEquals(4, $row['count']);
$job = new JobLogCleanupJob();
$this->assertTrue($job->run());
$jobLogs = JobLog::getAll();
$this->assertEquals(1, count($jobLogs));
$this->assertEquals($jobLog2->id, $jobLogs[0]->id);
$sql = 'select count(*) count from item';
$row = R::getRow($sql);
$this->assertEquals(3, $row['count']);
}
示例2: 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);
}
示例3: is_enduser
function is_enduser($id)
{
$sql = "select not_listed_in_search from usertypes where id = (select usertype from users where id = ?)";
require_once "config.php";
$data = R::getRow($sql, array($id));
return $data["not_listed_in_search"] == 1 ? 1 : 0;
}
示例4: testProperlyDeletingActivityItems
public function testProperlyDeletingActivityItems()
{
Yii::app()->user->userModel = User::getByUsername('super');
$count = R::getRow('select count(*) count from activity_item');
$this->assertEquals(0, $count['count']);
$account = AccountTestHelper::createAccountByNameForOwner('anAccount', Yii::app()->user->userModel);
$deleted = $account->delete();
$this->assertTrue($deleted);
$count = R::getRow('select count(*) count from activity_item');
$this->assertEquals(0, $count['count']);
$account2 = AccountTestHelper::createAccountByNameForOwner('anAccount2', Yii::app()->user->userModel);
$opportunity = OpportunityTestHelper::createOpportunityByNameForOwner('anOpp', Yii::app()->user->userModel);
$task = TaskTestHelper::createTaskWithOwnerAndRelatedAccount('aTask', Yii::app()->user->userModel, $account2);
$task->activityItems->add($opportunity);
$this->assertTrue($task->save());
$taskId = $task->id;
$task->forget();
RedBeansCache::forgetAll();
$count = R::getRow('select count(*) count from activity_item');
$this->assertEquals(2, $count['count']);
$deleted = $account2->delete();
$this->assertTrue($deleted);
$account2->forget();
$count = R::getRow('select count(*) count from activity_item');
$this->assertEquals(1, $count['count']);
RedBeansCache::forgetAll();
//Make sure things render ok even with the account deleted.
$content = ActivitiesUtil::renderSummaryContent(Task::getById($taskId), 'someUrl', LatestActivitiesConfigurationForm::OWNED_BY_FILTER_ALL, 'HomeModule');
}
示例5: testRun
public function testRun()
{
$quote = DatabaseCompatibilityUtil::getQuote();
//Create 2 imports, and set one with a date over a week ago (8 days ago) for the modifiedDateTime
$import = new Import();
$serializedData['importRulesType'] = 'ImportModelTestItem';
$import->serializedData = serialize($serializedData);
$this->assertTrue($import->save());
ImportTestHelper::createTempTableByFileNameAndTableName('importAnalyzerTest.csv', $import->getTempTableName());
$modifiedDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime(time() - 60 * 60 * 24 * 8);
$sql = "Update item set modifieddatetime = '" . $modifiedDateTime . "' where id = " . $import->getClassId('Item');
R::exec($sql);
$staleImportId = $import->id;
$import2 = new Import();
$serializedData['importRulesType'] = 'ImportModelTestItem';
$import2->serializedData = serialize($serializedData);
$this->assertTrue($import2->save());
ImportTestHelper::createTempTableByFileNameAndTableName('importAnalyzerTest.csv', $import2->getTempTableName());
$this->assertEquals(2, count(Import::getAll()));
$row = R::getRow('show tables like "' . $import->getTempTableName() . '"');
$this->assertNotEmpty($row);
$job = new ImportCleanupJob();
$this->assertTrue($job->run());
$row = R::getRow('show tables like "' . $import->getTempTableName() . '"');
$this->assertEmpty($row);
$imports = Import::getAll();
$this->assertEquals(1, count($imports));
$this->assertEquals($import2->id, $imports[0]->id);
}
示例6: testSaveAllMetadata
public function testSaveAllMetadata()
{
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
$this->assertTrue(ContactsModule::loadStartingData());
$messageLogger = new MessageLogger();
InstallUtil::autoBuildDatabase($messageLogger);
chdir(COMMON_ROOT . DIRECTORY_SEPARATOR . 'protected' . DIRECTORY_SEPARATOR . 'commands');
$command = "php zurmocTest.php manageMetadata super saveAllMetadata";
if (!IS_WINNT) {
$command .= ' 2>&1';
}
exec($command, $output);
// Check if data are saved for some specific View
$moduleMetadata = R::getRow("SELECT * FROM globalmetadata WHERE classname='NotesModule'");
$this->assertTrue($moduleMetadata['id'] > 0);
$this->assertTrue(strlen($moduleMetadata['serializedmetadata']) > 0);
// Check if data are saved for some specific View
$modelMetadata = R::getRow("SELECT * FROM globalmetadata WHERE classname='Note'");
$this->assertTrue($modelMetadata['id'] > 0);
$this->assertTrue(strlen($modelMetadata['serializedmetadata']) > 0);
// Check if data are saved for some specific View
$viewMetadata = R::getRow("SELECT * FROM globalmetadata WHERE classname='ContactsListView'");
$this->assertTrue($viewMetadata['id'] > 0);
$this->assertTrue(strlen($viewMetadata['serializedmetadata']) > 0);
}
示例7: countAll
public function countAll()
{
$row = R::getRow('select count(*) as count_all from `' . $this->table_name . '`');
if (isset($row['count_all'])) {
return (int) $row['count_all'];
} else {
return 0;
}
}
示例8: getChartData
public function getChartData()
{
$sql = static::makeSqlQuery(static::makeSearchAttributeData($this->autoresponder));
$row = R::getRow($sql);
$data = static::resolveChartDataBaseGroupElements();
foreach ($data as $index => $notUsed) {
if ($row[$index] != null) {
$data[$index] = $row[$index];
}
}
return $data;
}
示例9: authenticate
public function authenticate(Request $request)
{
\R::setup('mysql:host=localhost;dbname=gazingle', 'root', '');
$redis = Redis::connection();
$user = \R::getRow('select * from users where email = "' . $request->email . '"');
//return $user;
if ($request->password === \Crypt::decrypt($user['password'])) {
\Auth::loginUsingId($user['id']);
$redis->set(\Crypt::encrypt($request->email), $user['id']);
return $redis->get($request->email);
}
return response('Unauthorized.', 401);
}
示例10: testRecreateTable
public function testRecreateTable()
{
ReadPermissionsSubscriptionUtil::recreateTable('account_read_subscription');
$sql = 'INSERT INTO account_read_subscription VALUES (null, \'1\', \'2\', \'2013-05-03 15:16:06\', \'1\')';
R::exec($sql);
$accountReadSubscription = R::getRow("SELECT * FROM account_read_subscription");
$this->assertTrue($accountReadSubscription['id'] > 0);
$this->assertEquals(1, $accountReadSubscription['userid']);
$this->assertEquals(2, $accountReadSubscription['modelid']);
$this->assertEquals('2013-05-03 15:16:06', $accountReadSubscription['modifieddatetime']);
$this->assertEquals(1, $accountReadSubscription['subscriptiontype']);
$sql = 'DELETE FROM account_read_subscription';
R::exec($sql);
}
示例11: registerInitialUser
/**
* ユーザーが0件のときに初期ユーザーを登録する。
*
* @param array $userInfo
*/
public static function registerInitialUser($userInfo)
{
if (!isset($userInfo['sub'])) {
return;
}
$user_id = $userInfo['sub'];
$row = \R::getRow('SELECT COUNT(user_id) AS count FROM user');
if ($row['count'] == 0) {
$msg01 = "Administrator Group";
// 管理グループ
\R::exec('INSERT INTO `grp` (`grp_name`) VALUES (?)', array($msg01));
\R::exec('INSERT INTO `user` (`user_id`, `user_name`, `password`, `role`, `admin_flag`) VALUES (?, ?, ?, ?, ?)', array($user_id, '', '', '000', 1));
\R::exec('INSERT INTO `user_grp` (`user_id`, `grp_id`) VALUES (?, ?)', array($user_id, 1));
}
}
示例12: getChartData
/**
* @return array
*/
public function getChartData()
{
$chartData = array();
$groupedDateTimeData = static::makeGroupedDateTimeData($this->beginDate, $this->endDate, $this->groupBy, false);
foreach ($groupedDateTimeData as $groupData) {
$beginDateTime = DateTimeUtil::convertDateIntoTimeZoneAdjustedDateTimeBeginningOfDay($groupData['beginDate']);
$endDateTime = DateTimeUtil::convertDateIntoTimeZoneAdjustedDateTimeEndOfDay($groupData['endDate']);
$searchAttributedata = static::makeSearchAttributeData($endDateTime, $this->marketingList);
$sql = static::makeColumnSqlQuery($beginDateTime, $searchAttributedata);
$row = R::getRow($sql);
$columnData = array(MarketingChartDataProvider::NEW_SUBSCRIBERS_COUNT => ArrayUtil::getArrayValueAndResolveNullAsZero($row, static::NEW_SUBSCRIBERS_COUNT), MarketingChartDataProvider::EXISTING_SUBSCRIBERS_COUNT => ArrayUtil::getArrayValueAndResolveNullAsZero($row, static::EXISTING_SUBSCRIBERS_COUNT), 'displayLabel' => $groupData['displayLabel'], 'dateBalloonLabel' => $this->resolveDateBalloonLabel($groupData['displayLabel']));
$chartData[] = $columnData;
}
return $chartData;
}
示例13: printOverallHoneypotActivity
public function printOverallHoneypotActivity()
{
//TOTAL LOGIN ATTEMPTS
$db_query = "SELECT COUNT(*) AS logins FROM connections";
$row = R::getRow($db_query);
//echo '<strong>Total login attempts: </strong><h3>'.$row['logins'].'</h3>';
echo '<table><thead>';
echo '<tr>';
echo '<th>Total attack attempts</th>';
echo '<th>' . $row['logins'] . '</th>';
echo '</tr></thead><tbody>';
echo '</tbody></table>';
//TOTAL DISTINCT IPs
$db_query = "SELECT COUNT(DISTINCT source_ip) AS ips FROM connections";
$row = R::getRow($db_query);
//echo '<strong>Distinct source IPs: </strong><h3>'.$row['IPs'].'</h3>';
echo '<table><thead>';
echo '<tr>';
echo '<th>Distinct source IP addresses</th>';
echo '<th>' . $row['ips'] . '</th>';
echo '</tr></thead><tbody>';
echo '</tbody></table>';
//OPERATIONAL TIME PERIOD
$db_query = "SELECT MIN(timestamp) AS start, MAX(timestamp) AS end FROM connections";
$rows = R::getAll($db_query);
if (count($rows)) {
//We create a skeleton for the table
echo '<table><thead>';
echo '<tr class="dark">';
echo '<th colspan="2">Active time period</th>';
echo '</tr>';
echo '<tr class="dark">';
echo '<th>Start date (first attack)</th>';
echo '<th>End date (last attack)</th>';
echo '</tr></thead><tbody>';
//For every row returned from the database we add a new point to the dataset,
//and create a new table row with the data as columns
foreach ($rows as $row) {
echo '<tr class="light">';
echo '<td>' . date('l, d-M-Y, H:i A', strtotime($row['start'])) . '</td>';
echo '<td>' . date('l, d-M-Y, H:i A', strtotime($row['end'])) . '</td>';
echo '</tr>';
}
//Close tbody and table element, it's ready.
echo '</tbody></table>';
}
}
示例14: testRebuilt
public function testRebuilt()
{
ModelCreationApiSyncUtil::buildTable();
$sql = 'INSERT INTO ' . ModelCreationApiSyncUtil::TABLE_NAME . ' VALUES (null, \'ApiServiceName\', \'1\', \'Contact\', \'2013-05-03 15:16:06\')';
R::exec($sql);
$apiServiceCreationRow = R::getRow('SELECT * FROM ' . ModelCreationApiSyncUtil::TABLE_NAME);
$this->assertTrue($apiServiceCreationRow['id'] > 0);
$this->assertEquals('ApiServiceName', $apiServiceCreationRow['servicename']);
$this->assertEquals(1, $apiServiceCreationRow['modelid']);
$this->assertEquals('Contact', $apiServiceCreationRow['modelclassname']);
$this->assertEquals('2013-05-03 15:16:06', $apiServiceCreationRow['createddatetime']);
// Now test when table already exist
ModelCreationApiSyncUtil::buildTable();
$apiServiceCreationRow = R::getRow('SELECT COUNT(*) as totalRows FROM ' . ModelCreationApiSyncUtil::TABLE_NAME);
$this->assertEquals(1, $apiServiceCreationRow['totalRows']);
$sql = 'INSERT INTO ' . ModelCreationApiSyncUtil::TABLE_NAME . ' VALUES (null, \'ApiServiceName\', \'2\', \'Contact\', \'2013-06-03 15:16:06\')';
R::exec($sql);
$apiServiceCreationRow = R::getRow('SELECT COUNT(*) as totalRows FROM ' . ModelCreationApiSyncUtil::TABLE_NAME);
$this->assertEquals(2, $apiServiceCreationRow['totalRows']);
}
示例15: json_decode
}
$people_array = json_decode($peoples);
if ($people_array === FALSE || $people_array == NULL || empty($people_array)) {
//header('Content-type:text/json;charset=utf-8');
//echo json_encode(['result' => 'failed', 'error' => 'invalid argument peoples']);
//die();
}
// Get user info
R::addDatabase('kayako', $GLOBALS['db_kayako_url'], $GLOBALS['db_kayako_user'], $GLOBALS['db_kayako_pass']);
R::selectDatabase('kayako');
if (!R::testConnection()) {
exit('DB failed' . PHP_EOL);
}
R::freeze(true);
try {
$user = R::getRow(' SELECT su.userid,' . ' su.fullname, ' . ' sm.email,' . ' su.phone,' . ' su.userorganizationid,' . ' so.organizationname ' . ' FROM kayako_fusion.swusers su' . ' INNER JOIN kayako_fusion.swuseremails sm' . ' ON su.userid = sm.linktypeid' . ' AND sm.linktype = 1' . ' INNER JOIN kayako_fusion.swuserorganizations so' . ' ON so.userorganizationid = su.userorganizationid' . ' WHERE email = :email', [':email' => $user_name]);
} catch (Exception $e) {
header('Content-type:text/json;charset=utf-8');
echo json_encode(['result' => 'failed', 'error' => 'db error kayako', 'details' => $e->getMessage()]);
die;
}
R::close();
// Save frequent people
R::addDatabase('supportsr', $GLOBALS['db_supportsr_url'], $GLOBALS['db_supportsr_user'], $GLOBALS['db_supportsr_pass']);
R::selectDatabase('supportsr');
if (!R::testConnection()) {
exit('DB failed' . PHP_EOL);
}
R::freeze(true);
try {
R::begin();