本文整理汇总了PHP中R类的典型用法代码示例。如果您正苦于以下问题:PHP R类的具体用法?PHP R怎么用?PHP R使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了R类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createService
/**
* @param ServiceLocatorInterface $serviceLocator
* @return R
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
$rjhRedbeanService = new R();
$config = $serviceLocator->get('config');
$rjhRedbeanConfig = $config['rjhredbean'];
$connection = $rjhRedbeanConfig['connection'];
$dsn = $connection['dsn'];
$user = $connection['user'];
$password = $connection['password'];
$rjhRedbeanService->setup($dsn, $user, $password);
$rjhRedbeanService->freeze($rjhRedbeanConfig['freeze']);
$rjhRedbeanService->debug($rjhRedbeanConfig['debug']);
return $rjhRedbeanService;
}
示例2: testTainted
/**
* Test tainted.
*
* @return void
*/
public function testTainted()
{
testpack('Original Tainted Tests');
$redbean = R::$redbean;
$spoon = $redbean->dispense("spoon");
asrt($spoon->getMeta("tainted"), TRUE);
$spoon->dirty = "yes";
asrt($spoon->getMeta("tainted"), TRUE);
testpack('Tainted List test');
$note = R::dispense('note');
$note->text = 'abc';
$note->ownNote[] = R::dispense('note')->setAttr('text', 'def');
$id = R::store($note);
$note = R::load('note', $id);
asrt($note->isTainted(), FALSE);
// Shouldn't affect tainted
$note->text;
asrt($note->isTainted(), FALSE);
$note->ownNote;
asrt($note->isTainted(), TRUE);
testpack('Tainted Test Old Value');
$text = $note->old('text');
asrt($text, 'abc');
asrt($note->hasChanged('text'), FALSE);
$note->text = 'xxx';
asrt($note->hasChanged('text'), TRUE);
$text = $note->old('text');
asrt($text, 'abc');
testpack('Tainted Non-exist');
asrt($note->hasChanged('text2'), FALSE);
testpack('Misc Tainted Tests');
$bean = R::dispense('bean');
$bean->hasChanged('prop');
$bean->old('prop');
}
示例3: do_stuff
function do_stuff()
{
/* 26.9|0.0|0.0|31.4|0.00|0.00|0.00|0.00 */
$result = file_get_contents('http://ourproject.dyndns-server.com:8099/&');
echo $result;
$rs = explode('|', $result);
echo "\n";
$now = new DateTime();
$b = R::dispense('timedate');
$b->time = $now->format('Y-m-d H:i:s');
$b->T1 = $rs[0];
$b->T2 = $rs[1];
$b->T3 = $rs[2];
$b->T4 = $rs[3];
$b->V1 = $rs[4];
$b->V2 = $rs[5];
$b->V3 = $rs[6];
$b->V4 = $rs[7];
R::store($b);
echo $b->time;
echo "\n";
// MySQL datetime format
sleep(10);
// wait 20 seconds
do_stuff();
// call this function again
}
示例4: getUserExternalSystemIds
public static function getUserExternalSystemIds()
{
$columnName = ExternalSystemIdUtil::EXTERNAL_SYSTEM_ID_COLUMN_NAME;
RedBeanColumnTypeOptimizer::externalIdColumn(User::getTableName('User'), $columnName);
$sql = 'select ' . $columnName . ' from ' . User::getTableName('User');
return R::getCol($sql);
}
示例5: register
function register($data)
{
try {
include_once 'dbcon.php';
} catch (Exception $e) {
?>
<script type="text/javascript">
alert("Unable to connect to DB, Please contact Administrator");
</script>
<?php
}
$admin->uname = $username;
$admin->password = $password;
$admin->sh_name = $shName;
$admin->full_name = $fullName;
$admin->desc = $desc;
$admin->location = $location;
$admin->address = $address;
$admin->date_added = $dateAdded;
$admin->estd_year = $estddate;
try {
R::store($admin);
} catch (Exception $e) {
?>
<script type="text/javascript">
alert("Unable to save to DB, Please contact Administrator");
</script>
<?php
}
}
示例6: 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;
}
示例7: save
public function save()
{
GUMP::add_validator("unique", function ($field, $input, $param = NULL) {
$checkExistingUser = R::findOne('user', 'user=?', array($input));
if ($checkExistingUser == NULL) {
return FALSE;
} else {
return TRUE;
}
});
GUMP::add_validator("strong", function ($field, $input, $param = NULL) {
return checkPasswordStrength($input);
});
$rules = array('reseller_username' => 'required|alpha_numeric|max_len,10|min_len,6|unique', 'reseller_password' => 'required|max_len,10|min_len,7|strong');
$filters = array('reseller_username' => 'trim|sanitize_string', 'reseller_password' => 'trim|sanitize_string|md5');
$app = Slim::getInstance();
$post = $app->request()->post();
// $app - Slim main app instance
$postValues = $gump->filter($post, $filters);
$validated = $gump->validate($gump->filter($postValues, $filters), $rules);
if ($validated === TRUE) {
$createUser = R::dispense('user');
$createUser->user = $postValues['reseller_username'];
$createUser->user = $postValues['reseller_password'];
} else {
$this->setError($gump->get_readable_errors(true));
}
if ($this->getError() == "") {
$this->fails = FALSE;
} else {
$this->fails = TRUE;
}
}
示例8: 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;
}
}
示例9: execute
static function execute($number = 5)
{
if (!is_numeric($number)) {
throw new Exception('Number must be numeric');
}
$callables = R::findAll('queueitem', 'status = "open" ORDER BY id DESC LIMIT ' . $number);
$c = 0;
foreach (array_values($callables) as $index => $calleble) {
$c++;
if ($calleble->done) {
$c--;
continue;
}
if ($c >= $number) {
break;
}
$serializer = new Serializer();
$closure = $serializer->unserialize($calleble->callser);
//// $calleble->status = 'busy';
// R::store($calleble);
$closure();
$calleble->status = 'done';
$calleble->done = true;
$calleble->doneat = time();
R::store($calleble);
}
return;
}
示例10: delete_event
function delete_event($id)
{
$event = R::load('events', $id);
//reloads our event
R::trash($event);
//for one bean
}
示例11: insertUser
/**
* @return int|string
* @throws \RedBeanPHP\RedException
*/
function insertUser()
{
$users = R::dispense('users');
$users->fname = 'Abhishek';
$users->lname = 'Saha';
return R::store($users);
}
示例12: process
public function process(array $documents, &$context)
{
$doc = $documents[self::URL_MEDIA];
$dom = self::getDOM($doc);
$xpath = new DOMXPath($dom);
//chapter count
preg_match_all('#([0-9]+|Unknown)#', self::getNodeValue($xpath, '//span[text() = \'Chapters:\']/following-sibling::node()[self::text()]'), $matches);
$chapterCount = Strings::makeInteger($matches[0][0]);
//volume count
preg_match_all('#([0-9]+|Unknown)#', self::getNodeValue($xpath, '//span[text() = \'Volumes:\']/following-sibling::node()[self::text()]'), $matches);
$volumeCount = Strings::makeInteger($matches[0][0]);
//serialization
$serializationMalId = null;
$serializationName = null;
$q = $xpath->query('//span[text() = \'Serialization:\']/../a');
if ($q->length > 0) {
$node = $q->item(0);
preg_match('#/magazine/([0-9]+)$#', $node->getAttribute('href'), $matches);
$serializationMalId = Strings::makeInteger($matches[1]);
$serializationName = Strings::removeSpaces($q->item(0)->nodeValue);
}
$media =& $context->media;
$media->chapters = $chapterCount;
$media->volumes = $volumeCount;
$media->serialization_id = $serializationMalId;
$media->serialization_name = $serializationName;
R::store($media);
}
示例13: __construct
/**
* Construct a new database object.
* @param $settings
*/
public function __construct($settings)
{
$this->database = DatabaseManager::connect($settings["host"], $settings["port"], $settings["user"], $settings["pass"], $settings["name"], isset($settings["utf8"]) ? $settings["utf8"] : true);
// Debug
global $settings;
R::debug($settings["development"]);
}
示例14: getSubscribers
function getSubscribers($id)
{
$subs = R::getAll("select * from subscription where category_id='{$id}'");
if ($subs) {
return $subs;
}
}
示例15: 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');
}