本文整理汇总了PHP中R::findOrCreate方法的典型用法代码示例。如果您正苦于以下问题:PHP R::findOrCreate方法的具体用法?PHP R::findOrCreate怎么用?PHP R::findOrCreate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类R
的用法示例。
在下文中一共展示了R::findOrCreate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
function __construct($email = null)
{
$email = urldecode($email);
// halt on error: wrong email format
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
throw new Exception('JAC_User_WrongEmail: Format of the provided email address is not correct.');
return;
}
// email address is valid - assign the value
$this->email = $email;
// load the user or create one if it does not exists (by email address)
$this->dbPointer = R::findOrCreate('user', array('email' => $email));
// assign the values from DB
$this->name = $this->dbPointer->name;
$this->id = $this->dbPointer->id;
}
示例2: markUserAsUnsynced
/**
* mark user as unsynced in cased user is updated
* @param int $userId id of the user to be marked as unsynced
* @return boolean
* **/
public function markUserAsUnsynced($userId)
{
$userRow = \R::findOrCreate($this->_name, array("users_id" => $userId));
$userRow->ams_sync_status = 0;
$userRow->amt_sync_status = 0;
$userRow->dmb_sync_status = 0;
try {
$this->_redBeans->store($userRow);
// //lets send ipn to all clients
// $objIpnHandler = new ipn\IpnHandler();
// $objIpnHandler->sendIpnForUpdatedUser($userId);
return true;
} catch (\Exception $ex) {
return false;
}
return false;
}
示例3: trim
if (in_array($img_base64, $null_image) !== FALSE) {
$img_base64 = NULL;
}
}
$available_td_list = $qp->find('.bibItemsEntry td:contains("可流通")');
for ($i = 0; $i < $available_td_list->size(); $i++) {
$call_number = $available_td_list->eq($i)->prev()->text();
$call_number = trim($call_number);
$location = $available_td_list->eq($i)->prev()->prev()->text();
$location = trim($location);
$data[] = array("title" => $title, "call_number" => $call_number, "location" => $location, "isbn" => $isbn, "img" => $img_base64);
}
// $data = array(
// "error" => "NOT_FOUND"
// );
}
}
// if (htmlqp($url, '.bibItemsEntry td:contains("可流通")')->size() > 0) {
// ---------------------------
// 轉換
$json = json_encode($data, JSON_UNESCAPED_UNICODE);
//$json = json_encode($data);
// ---------------------------
// 備份快取資料
$result = R::findOrCreate('cache_query_result', ['isbn' => $isbn]);
$result->isbn = $isbn;
$result->json = $json;
$result->timestamp = time();
R::store($result);
echo $json;
book_list_log($json);