当前位置: 首页>>代码示例>>PHP>>正文


PHP R::dispense方法代码示例

本文整理汇总了PHP中R::dispense方法的典型用法代码示例。如果您正苦于以下问题:PHP R::dispense方法的具体用法?PHP R::dispense怎么用?PHP R::dispense使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在R的用法示例。


在下文中一共展示了R::dispense方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addfwconfig

/**
 * Store a new framework config item
 * @param string    $name
 * @param string    $value
 *
 * @return void
 **/
function addfwconfig($name, $value)
{
    $fwc = R::dispense('fwconfig');
    $fwc->name = $name;
    $fwc->value = $value;
    R::store($fwc);
}
开发者ID:rivets,项目名称:framework,代码行数:14,代码来源:install.php

示例2: addFollower

function addFollower($userid)
{
    $following = R::dispense('following');
    $following->userid = $_SESSION['user_id'];
    $following->follows = $userid;
    $id = R::store($following);
}
开发者ID:alikhan890,项目名称:minitwitter,代码行数:7,代码来源:ajax.php

示例3: doDeleteById

 public static function doDeleteById($id)
 {
     $user = R::dispense('user');
     $user->id = $id;
     R::trash($user);
     //for one bean
 }
开发者ID:xinerd,项目名称:SP_ROI,代码行数:7,代码来源:UserDAOImpl.class.php

示例4: save

 public function save()
 {
     if ($this->is_validated()) {
         if ($this->isDublicateUser($this->validated_data['user_name'])) {
             $this->setError('Duplicate username,Please choose another');
         } elseif ($this->isNotStrongPassword($this->validated_data['user_password'])) {
             $this->setError('Please choose strong password');
         } else {
             $clientreseller = R::dispense("user");
             $clientreseller->fullname = $this->validated_data['reseller_user_id'];
             $clientreseller->linetitle = $this->validated_data['reseller_line_id'];
             $clientreseller->currencyrate = $this->validated_data['reseller_currency_conversion_rate'];
             $clientreseller->username = $this->validated_data['reseller_cpanel_user_name'];
             $clientreseller->password = md5(SALT . $this->validated_data['reseller_cpanel_password']);
             $clientreseller->resellerlevel = $this->validated_data['reseller_level'];
             $clientreseller->note = $this->validated_data['reseller_notes'];
             $clientreseller->type = 4;
             $clientreseller->createdate = CURRENT_DTT;
             $clientreseller->updatedate = CURRENT_DTT;
             $clientreseller->createby = 1001;
             $clientreseller->isactive = 1;
             $clientresellerid = R::store($clientreseller);
         }
     }
     if ($this->getError() == "") {
         $this->fails = FALSE;
     } else {
         $this->fails = TRUE;
     }
 }
开发者ID:bogiesoft,项目名称:Slim_PHP_Project,代码行数:30,代码来源:clientreseller_library.php

示例5: create_group

 public function create_group($name)
 {
     $group = R::dispense('group');
     $group->name = $name;
     R::store($group);
     return $group;
 }
开发者ID:g2design,项目名称:g2-modules,代码行数:7,代码来源:Permission.php

示例6: create

 /**
  * creates a user with the $data provided in local DB
  *
  * @param  array  $data [description]
  * @return [type]       [description]
  */
 function create($data = array(), &$errorMessage)
 {
     // require password hashing library
     require_once ROOT . '/lib/passwordHash.php';
     $bungieData = file_get_contents('http://www.bungie.net/Platform/User/SearchUsersPaged/' . $data['gamerid'] . '/1/');
     $bungie = json_decode($bungieData, true);
     // provided we get results
     if ($bungie['Response']['totalResults'] > 0) {
         // get user from bungie
         $buser = $bungie['Response']['results'][0];
         // create user in ocd
         $user = R::dispense('users');
         // collate data
         $user['bungie'] = $buser['membershipId'];
         $user['gamerid'] = $data['gamerid'];
         $user['platform'] = $data['platform'];
         $user['email'] = $data['email'];
         $user['password'] = lib\PasswordHash::create_hash($data['password']);
         $user['level'] = 100;
         $user['avatar'] = 'https://www.bungie.net' . $buser['profilePicturePath'];
         $uid = R::store($user);
         if ($uid != null) {
             return true;
         }
     } else {
         $errorMessage = "We couldn't find you in Bungie's Destiny DB - there may be an update to the DB in progress, please try again later!";
     }
     return false;
 }
开发者ID:croger46,项目名称:oceanicdestiny,代码行数:35,代码来源:user.php

示例7: 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');
 }
开发者ID:daviddeutsch,项目名称:redbean-adaptive,代码行数:36,代码来源:Foreignkeys.php

示例8: create

 public static function create($name)
 {
     $item = R::dispense('position');
     $item->name = $name;
     $id = R::store($item);
     return $id;
 }
开发者ID:Avimunk,项目名称:Que,代码行数:7,代码来源:position.php

示例9: userprofile

 public function userprofile()
 {
     $allPostVars = $app->request->post();
     $profile = R::dispense('user_profile');
     $profile->title = $allPostVars['title'];
     $profile->firstname = $allPostVars['firstname'];
     $profile->middlename = $allPostVars['middlename'];
     $profile->lastname = $allPostVars['lastname'];
     $profile->dob = $allPostVars['dob'];
     $profile->numdependents = $allPostVars['numdependents'];
     $profile->ausdrivlicnum = $allPostVars['ausdrivlicnum'];
     $profile->email_primary = $allPostVars['email_primary'];
     $profile->mobile = $allPostVars['mobile'];
     $profile->home_ph = $allPostVars['home_ph'];
     $profile->work_ph = $allPostVars['work_ph'];
     $profile->unit_num = $allPostVars['unit_num'];
     $profile->street = $allPostVars['street'];
     $profile->suburb = $allPostVars['suburb'];
     $profile->postcode = $allPostVars['postcode'];
     $profile->state = $allPostVars['state'];
     $profile->gender = $allPostVars['gender'];
     $datetime = date_create()->format('Y-m-d');
     $profile->date_joined = $datetime;
     //echo ($profile->test());
     //print_r($allPostVars);
     //$profile = R::dispense('tasks');
     //$profile->task = $allPostVars['task'];
     //$profile->user_id = $allPostVars['user_id'];
     $id = R::store($profile);
 }
开发者ID:dazmiller,项目名称:red4,代码行数:30,代码来源:UserProfile.php

示例10: testRebuilder

 /**
  * Test SQLite table rebuilding.
  * 
  * @return void
  */
 public function testRebuilder()
 {
     $toolbox = R::$toolbox;
     $adapter = $toolbox->getDatabaseAdapter();
     $writer = $toolbox->getWriter();
     $redbean = $toolbox->getRedBean();
     $pdo = $adapter->getDatabase();
     R::dependencies(array('page' => array('book')));
     $book = R::dispense('book');
     $page = R::dispense('page');
     $book->ownPage[] = $page;
     $id = R::store($book);
     $book = R::load('book', $id);
     asrt(count($book->ownPage), 1);
     asrt((int) R::getCell('SELECT COUNT(*) FROM page'), 1);
     R::trash($book);
     asrt((int) R::getCell('SELECT COUNT(*) FROM page'), 0);
     $book = R::dispense('book');
     $page = R::dispense('page');
     $book->ownPage[] = $page;
     $id = R::store($book);
     $book = R::load('book', $id);
     asrt(count($book->ownPage), 1);
     asrt((int) R::getCell('SELECT COUNT(*) FROM page'), 1);
     $book->added = 2;
     R::store($book);
     $book->added = 'added';
     R::store($book);
     R::trash($book);
     asrt((int) R::getCell('SELECT COUNT(*) FROM page'), 0);
 }
开发者ID:daviddeutsch,项目名称:redbean-adaptive,代码行数:36,代码来源:Rebuild.php

示例11: loginUser

 public function loginUser($username, $password)
 {
     //Check if username already exists
     $user = R::findOne('user', '  username = ? ', [strtolower($username)]);
     if ($user == NULL) {
         $error = new ErrorMessage("The username or the password is wrong!");
         return json_encode($error);
     }
     if (hash('sha512', $password . $user->salt) != $user->password) {
         $error = new ErrorMessage("The username or the password is wrong!");
         return json_encode($error);
     }
     //createSession
     $session_key = $this->random_string(128);
     $session = R::findOne('session', '  id = ? ', [$user->id]);
     if ($session == NULL) {
         $session = R::dispense('session');
         $session->token = $session_key;
         $session->user_id = $user->id;
         $id = R::store($session);
         $data = array("token" => $session_key, "public_key" => $user->public_key, "private_key" => $user->private_key);
         return json_encode($data);
     } else {
         $session->token = $session_key;
         $session->user_id = $user->id;
         $id = R::store($session);
         $data = array("token" => $session_key, "public_key" => $user->public_key, "private_key" => $user->private_key);
         return json_encode($data);
     }
 }
开发者ID:nebulak,项目名称:PrivateCircle,代码行数:30,代码来源:UserTool.php

示例12: save

 public function save()
 {
     if ($this->is_validated()) {
         if ($this->isDublicateUser($this->validated_data['user_name'])) {
             $this->setError('Duplicate username,Please choose another');
         } elseif ($this->isNotStrongPassword($this->validated_data['user_password'])) {
             $this->setError('Please choose strong password');
         } else {
             print_r($this->validated_data);
             $message = R::dispense("messageinfo");
             echo $this->validated_data['user_full_name'];
             exit;
             $message->fullname = $this->validated_data['user_full_name'];
             $message->username = $this->validated_data['user_name'];
             $message->password = md5(SALT . $this->validated_data['user_password']);
             $message->accesslevel = $this->validated_data['user_permission'];
             $message->currency = $this->validated_data['user_currency'];
             $message->email = $this->validated_data['user_email'];
             $message->phone = $this->validated_data['user_mobile'];
             $message->note = $this->validated_data['user_notes'];
             $message->createdate = CURRENT_DTT;
             $message->updatedate = CURRENT_DTT;
             $message->createby = 1001;
             $message->isactive = 0;
             $id = R::store($message);
             echo $id;
         }
     }
     if ($this->getError() == "") {
         $this->fails = FALSE;
     } else {
         $this->fails = TRUE;
     }
 }
开发者ID:bogiesoft,项目名称:Slim_PHP_Project,代码行数:34,代码来源:message_library.php

示例13: testTypes

 /**
  * Test types.
  * Test how RedBeanPHP OODB and OODBBean handle type and type casts.
  * 
  * Rules:
  * 
  * 1. before storing a bean all types are preserved except booleans (they are converted to STRINGS '0' or '1')
  * 2. after store-reload all bean property values are STRINGS or NULL 
  *    (or ARRAYS but that's only from a user perspective because these are lazy loaded)
  * 3. the ID returned by store() is an INTEGER (if possible; on 32 bit systems overflowing values will be cast to STRINGS!)
  * 
  * After loading:
  * ALL VALUES EXCEPT NULL -> STRING
  * NULL -> NULL
  * 
  * @note Why not simply return bean->id in store()? Because not every driver returns the same type:
  * databases without insert_id support require a separate query or a suffix returning STRINGS, not INTEGERS.
  * 
  * @note Why not preserve types? I.e. I store integer, why do I get back a string?
  * Answer: types are handled different across database platforms, would cause overhead to inspect every value for type,
  * also PHP is a dynamically typed language so types should not matter that much. Another reason: due to the nature
  * of RB columns in the database might change (INT -> STRING) this would cause return types to change as well which would
  * cause 'cascading errors', i.e. a column gets widened and suddenly your code would break.
  * 
  * @note Unfortunately the 32/64-bit issue cannot be tested fully. Return-strategy store() is probably the safest
  * solution.
  * 
  * @return void
  */
 public function testTypes()
 {
     testpack('Beans can only contain STRING and NULL after reload');
     R::nuke();
     $bean = R::dispense('bean');
     $bean->number = 123;
     $bean->float = 12.3;
     $bean->bool = false;
     $bean->bool2 = true;
     $bean->text = 'abc';
     $bean->null = null;
     $bean->datetime = new DateTime('NOW', new DateTimeZone('Europe/Amsterdam'));
     $id = R::store($bean);
     asrt(is_int($id), TRUE);
     asrt(is_float($bean->float), TRUE);
     asrt(is_integer($bean->number), TRUE);
     asrt(is_string($bean->bool), TRUE);
     asrt(is_string($bean->bool2), TRUE);
     asrt(is_string($bean->datetime), TRUE);
     asrt(is_string($bean->text), TRUE);
     asrt(is_null($bean->null), TRUE);
     $bean = R::load('bean', $id);
     asrt(is_string($bean->id), TRUE);
     asrt(is_string($bean->float), TRUE);
     asrt(is_string($bean->number), TRUE);
     asrt(is_string($bean->bool), TRUE);
     asrt(is_string($bean->bool2), TRUE);
     asrt(is_string($bean->datetime), TRUE);
     asrt(is_string($bean->text), TRUE);
     asrt(is_null($bean->null), TRUE);
     asrt($bean->bool, '0');
     asrt($bean->bool2, '1');
 }
开发者ID:daviddeutsch,项目名称:redbean-adaptive,代码行数:62,代码来源:Typechecking.php

示例14: store_file

 function store_file()
 {
     $value = $this->value;
     //Save the file inside the database
     $file = R::dispense('file');
     $filename = $value[G2_FormMagic::FILE_NAME];
     $filename = preg_replace("([^\\w\\s\\d\\-_~,;:\\[\\]\\(\\).])", '', $filename);
     // Remove any runs of periods (thanks falstro!)
     $filename = preg_replace("([\\.]{2,})", '', $filename);
     //Move the file to an upload directory;
     $directory = "uploads/";
     //check if the current file exist. If it does update the name
     $count = 1;
     $start_looking = $filename;
     while (file_exists($directory . $start_looking)) {
         $start_looking = str_replace('.' . Mvc_Functions::get_extension($filename), '', $filename) . "_{$count}" . '.' . Mvc_Functions::get_extension($filename);
         $count++;
     }
     $filename = $start_looking;
     $full_uri = $directory . $start_looking;
     if (!is_dir(dirname($full_uri))) {
         mkdir(dirname($full_uri), 0777, true);
     }
     if (!file_exists($value[G2_FormMagic::FILE_URI])) {
         return;
     }
     move_uploaded_file($value[G2_FormMagic::FILE_URI], $full_uri);
     //Save the file to database
     $file->name = $filename;
     $file->uri = $full_uri;
     R::store($file);
     $this->area->file = $file;
 }
开发者ID:g2design,项目名称:g2-modules,代码行数:33,代码来源:File.php

示例15: douban_callback

function douban_callback()
{
    OAuthRequester::requestAccessToken(DOUBAN_KEY, $_SESSION['oauth_token'], 0, 'POST', $options = array('oauth_verifier' => $_SESSION['oauth_token']));
    $req = new OAuthRequester('http://api.douban.com/people/' . urlencode('@me'), 'get');
    $res = $req->doRequest();
    $user_data = new SimpleXMLElement($res['body']);
    $uid = array_pop(explode('/', $user_data->id));
    $auth_type = 'douban';
    $auth = R::findOne('oauth', "uid=? AND type=?", array($uid, $auth_type));
    if (!$auth) {
        $auth = R::dispense('oauth');
        $auth->uid = $uid;
        $auth->type = $auth_type;
        $encrypt_key = rand(100000, 999999);
        $auth->secret = $encrypt_key;
    } else {
        $encrypt_key = $auth->secret;
    }
    $cookie_str = sha1(implode('', array($uid, $auth_type, $_SERVER['REMOTE_ADDR'], $_SERVER['HTTP_USER_AGENT'], $encrypt_key)));
    $expire = time() + 3600 * 24 * 365;
    setcookie('s', $cookie_str, $expire);
    setcookie('auth_type', $auth_type, $expire);
    setcookie('uid', $uid, $expire);
    $auth->setMeta('buildcommand.unique', array(array('uid', 'type')));
    $auth->setMeta('buildcommand.indexes', array('uid' => 'uid'));
    R::store($auth);
}
开发者ID:reusee,项目名称:defphp,代码行数:27,代码来源:douban_oauth.php


注:本文中的R::dispense方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。