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


PHP R::find方法代码示例

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


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

示例1: constructRelatedBeansAndModels

 /**
  * Handles constructing the relatedBeansAndModels with special attention to the case where it is PolyOneToMany
  * @param string $modelClassName
  * @param mixed $sqlOrBean
  */
 private function constructRelatedBeansAndModels($modelClassName, $sqlOrBean = '')
 {
     assert('is_string($sqlOrBean) || $sqlOrBean instanceof RedBean_OODBBean');
     $tableName = RedBeanModel::getTableName($modelClassName);
     if (is_string($sqlOrBean)) {
         $this->relatedBeansAndModels = array_values($beans = R::find($tableName, $sqlOrBean));
     } else {
         assert('$sqlOrBean instanceof RedBean_OODBBean');
         $this->bean = $sqlOrBean;
         try {
             if ($this->bean->id > 0) {
                 if ($this->polyName != null) {
                     $value = array();
                     $values['id'] = $this->bean->id;
                     $values['type'] = $this->bean->getMeta('type');
                     $this->relatedBeansAndModels = array_values(R::find($tableName, strtolower($this->polyName) . '_id = :id AND ' . strtolower($this->polyName) . '_type = :type', $values));
                 } else {
                     $relatedIds = ZurmoRedBeanLinkManager::getKeys($this->bean, $tableName);
                     $this->relatedBeansAndModels = array_values(R::batch($tableName, $relatedIds));
                 }
             } else {
                 $this->relatedBeansAndModels = array();
             }
         } catch (RedBean_Exception_SQL $e) {
             // SQLSTATE[42S02]: Base table or view not found...
             // SQLSTATE[42S22]: Column not found...
             if (!in_array($e->getSQLState(), array('42S02', '42S22'))) {
                 throw $e;
             }
             $this->relatedBeansAndModels = array();
         }
     }
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:38,代码来源:RedBeanOneToManyRelatedModels.php

示例2: actionViewConversation

 protected function actionViewConversation()
 {
     // create the user object
     $this->user = $this->setUser($this->request['user']);
     // halt on fail
     if (!$this->user) {
         return;
     }
     // create the receipient object
     $this->receipient = $this->setReceipient($this->request['receipient']);
     // halt on fail
     if (!$this->receipient) {
         return;
     }
     // get the messages between the user and receipient
     $rows = R::find('message', '  (user_id = :user_id AND receipient_id = :receipient_id)
         OR (user_id = :receipient_id AND receipient_id = :user_id)', array(':user_id' => $this->user->id, ':receipient_id' => $this->receipient->id));
     // convert array into bean objects
     $messages = R::convertToBeans('message', $rows);
     // create message objects from bean objects
     $conversation = array();
     foreach ($messages as $id => $message) {
         $conversation[$id] = new Message($message);
     }
     // add them to the data array for output
     $this->data = $conversation;
 }
开发者ID:esamo,项目名称:WebFoundary_PHPDeveloperTest,代码行数:27,代码来源:class-communicator.php

示例3: show_Chat

    public function show_Chat()
    {
        $lastMessage = $_POST["time"];
        if ($lastMessage < 0 || !is_numeric($lastMessage)) {
            $this->error('Invalid lastMessage-Timestamp');
        }
        if ($lastMessage < time() - CHAT_LIFETIME) {
            $lastMessage = time() - CHAT_LIFETIME;
        }
        $messages = R::find('chat_message', ' map = ? AND time > ?
		AND ((type = ? || (type = ? AND visible_for_id = ?)) || player_id = ?) ORDER BY time ASC', array($this->mapPosition->map, $lastMessage, 'public', 'private', $this->user->id, $this->user->id));
        $m = array();
        $latest = $lastMessage;
        foreach ($messages as $msg) {
            $to = "";
            $type = $msg->player_id != null && $msg->player_id == $this->user->id ? "own" : $msg->type;
            if ($type == "own" && $msg->visible_for_id != null) {
                $p = R::findOne('user', ' id = ?', array($msg->visible_for_id));
                if ($p != false) {
                    $to = htmlspecialchars($p->username);
                }
            }
            $m[] = array('time' => date("H:i:s", $msg->time), 'author' => htmlspecialchars($msg->author), 'pid' => $msg->player_id != null ? $msg->player_id : "-1", 'text' => $msg->text, 'type' => $type, 'to' => $to);
            $latest = $msg->time;
        }
        $this->output('messages', $m);
        $this->output('timestamp', $latest);
    }
开发者ID:agrafix,项目名称:managerslife,代码行数:28,代码来源:Ajax_Map.class.php

示例4: clean

 public static function clean($f3, $filename)
 {
     $total_filesize = R::getCell('select sum(filesize) as total_filesize from cache');
     $cache_total_filesize_limit = $f3->get("UPLOAD.cache_total_size_limit");
     $cache_total_filesize_limit = PFH_File_helper::convert_filesize_in_bytes($cache_total_filesize_limit);
     if ($total_filesize > $cache_total_filesize_limit) {
         $caches = R::find("cache", "ORDER BY datetime");
         $count = count($caches);
         // 只有一個不刪除
         //if ($count < 2) {
         //    return;
         //}
         foreach ($caches as $key => $cache) {
             //不刪除最後一個
             //if ($key > $count - 1) {
             //    return;
             //}
             if ($cache->path === $filename) {
                 continue;
             }
             //throw new Exception("$key $cache->path");
             //echo $cache->path . "<br />";
             if (is_file($cache->path)) {
                 unlink($cache->path);
             }
             $total_filesize = $total_filesize - $cache->filesize;
             R::trash($cache);
             if ($total_filesize < $cache_total_filesize_limit) {
                 break;
             }
         }
     }
 }
开发者ID:rivalinx,项目名称:php-file-host,代码行数:33,代码来源:PFH_Archive_cache.php

示例5: exec

 public function exec($params)
 {
     $data = array();
     $module = isset($params['module']) ? $params['module'] : 'servers';
     $view = isset($params['view']) ? $params['view'] : 'index';
     $data['module'] = $module;
     $data['view'] = $view;
     $data['title'] = '';
     $data['uri'] = '/' . $module . '/' . $view;
     $data['uriArray'] = array('/', $module, $view);
     switch ($module) {
         case 'domains':
             $domains = R::find('domain');
             $data['title'] = 'Domains';
             $data['domains'] = $domains;
             $data['template'] = 'design/desktop/templates/domains.tpl.php';
             break;
         case 'accounts':
             $data['title'] = 'Domains to accounts';
             $data['domains'] = getUnrelatedMainDomains();
             $data['template'] = 'design/desktop/templates/accounts.tpl.php';
             break;
         case 'servers':
             $data['title'] = 'Servers';
             $data['hasFieldSelector'] = true;
             $data['avaliableFields'] = getAvaliableFields('servers');
             $data['enabledFields'] = getEnabledFields('servers');
             $data['serversGrouped'] = getGroupedByType();
             $data['template'] = 'design/desktop/templates/servers_list.tpl.php';
             break;
         case 'search':
             $data['title'] = 'Search';
             $data['template'] = 'design/desktop/templates/search.tpl.php';
             break;
         case 'cleanup':
             $data['title'] = 'Cleanup';
             $data['template'] = 'design/desktop/templates/cleanup.tpl.php';
             break;
         default:
             $data['title'] = '404 Page not found';
             $data['template'] = 'design/desktop/templates/error.tpl.php';
             $data['error'] = array('code' => '404', 'msg' => 'Page not found');
             break;
     }
     mvc\render('design/desktop/templates/header.tpl.php', $data);
     mvc\render('design/desktop/templates/top_menu.tpl.php', $data);
     if (isset($data['hasFieldSelector']) && $data['hasFieldSelector']) {
         mvc\render('design/desktop/templates/field_selector.tpl.php', $data);
     }
     if (mvc\retrieve('debug')) {
         $data['values']['params'] = $params;
         mvc\render('design/desktop/templates/debug.tpl.php', $data);
     }
     mvc\render($data['template'], $data);
     mvc\render('design/desktop/templates/footer.tpl.php', $data);
 }
开发者ID:henrik-farre,项目名称:domains,代码行数:56,代码来源:class.contentHandler.php

示例6: show_Inventory

 public function show_Inventory()
 {
     $items = R::find('inventory', ' user_id = ?', array($this->user->getID()));
     $i = array();
     foreach ($items as $itm) {
         $item = R::load('inventory', $itm->getID());
         $i[] = array("id" => $item->getID(), "name" => $item->item->name, "desc" => str_replace('{param}', $item->param, $item->item->desc), "is_usable" => $item->item->usable == 1 ? true : false, "value" => $item->item->value, "usable_link" => $item->item->usable_link_desc, "amount" => $item->amount, "type" => $item->item->type);
     }
     $this->output('items', $i);
 }
开发者ID:agrafix,项目名称:managerslife,代码行数:10,代码来源:Ajax_User.class.php

示例7: getall

function getall()
{
    try {
        $articles = R::find('articles');
        echo json_encode(R::exportAll($articles));
    } catch (Exception $e) {
        $app->response()->status(400);
        $app->response()->header('X-Status-Reason', $e->getMessage());
    }
}
开发者ID:limweb,项目名称:webappservice,代码行数:10,代码来源:samplecrud.php

示例8: index

 function index($f3)
 {
     $D = \R::find($this->model_name(), 'ORDER BY displayname ASC');
     if ($D) {
         $f3->set('data', \R::exportAll($D));
     } else {
         $f3->set('data', '');
     }
     show_page($f3, $this->template_name() . '.index');
 }
开发者ID:neyre,项目名称:tools.olin.edu,代码行数:10,代码来源:base.php

示例9: totalcount

 function totalcount()
 {
     include_once 'dbcon.php';
     $college = R::find('college', 'delflg=?', ['N']);
     $count = 0;
     if ($college != null && !empty($college)) {
         $count = sizeof($college);
     }
     return $count;
 }
开发者ID:4sujittiwari,项目名称:AdminPanel,代码行数:10,代码来源:college.php

示例10: getList

 /**
  * Return all records for a type
  * @param string $type Database table
  * @return string JSON All of the records and their contents
  * @throws API\Exceptions\APIException No records found, 404
  */
 public static function getList($type)
 {
     $beans = R::find($type);
     $response = R::exportAll($beans);
     if (sizeof($response) > 0) {
         return new JSON(array("data" => $response));
     } else {
         throw new APIException("No " . $type . " records found.", 404);
     }
 }
开发者ID:paulosouzainfo,项目名称:PHP-RapidREST,代码行数:16,代码来源:RapidRest.php

示例11: totalcount

 function totalcount()
 {
     include_once 'dbcon.php';
     $review = R::find('reviews', 'delflg=N');
     $count = 0;
     if ($review != null && !empty($review)) {
         $count = sizeof($review);
     }
     return $count;
 }
开发者ID:4sujittiwari,项目名称:AdminPanel,代码行数:10,代码来源:reviewmodel.php

示例12: loadTable

 private function loadTable()
 {
     $rows = array();
     $r = R::find($this->currentTable, ' 1 ORDER BY id ASC LIMIT 0,30');
     foreach ($r as $row) {
         foreach ($this->dbTables[$this->currentTable] as $field) {
             $rows[$row->getID()][$field] = $row->{$field};
         }
     }
     Framework::TPL()->assign('tableRows', $rows);
 }
开发者ID:agrafix,项目名称:managerslife,代码行数:11,代码来源:Game_Db_admin.class.php

示例13: getMessagesForUser

 public function getMessagesForUser($user_id)
 {
     $messageList = R::find('message', '  recipient_id = ? ', [$user_id], ' ORDER BY date ASC ');
     $messages = array();
     foreach ($messageList as $message) {
         $sender = R::findOne('user', '  id = ? ', [$message->sender_id]);
         $currentElement = array("sender" => $sender->username, "content" => $message->content, "date" => $message->date, "m_id" => $message->id);
         array_push($messages, $currentElement);
     }
     return json_encode($messages);
 }
开发者ID:nebulak,项目名称:PrivateCircle,代码行数:11,代码来源:MessageManager.php

示例14: getModelByExternalSystemIdAndModelClassName

 /**
  * Given an external system id and model class name, try to find the associated model if it exists. If it is
  * not found, a NotFoundException will be thrown.  Otherwise the model will be made and returned.
  * @param string $id
  * @param string $modelClassName
  */
 public static function getModelByExternalSystemIdAndModelClassName($id, $modelClassName)
 {
     assert('$id != null && is_string($id)');
     assert('is_string($modelClassName)');
     $tableName = $modelClassName::getTableName($modelClassName);
     $beans = R::find($tableName, ExternalSystemIdUtil::EXTERNAL_SYSTEM_ID_COLUMN_NAME . " = '{$id}'");
     assert('count($beans) <= 1');
     if (count($beans) == 0) {
         throw new NotFoundException();
     }
     return RedBeanModel::makeModel(end($beans), $modelClassName);
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:18,代码来源:ExternalSystemIdSuppportedSanitizerUtil.php

示例15: handle

 /**
  * Handle profile operations /data/xxxx
  *
  * @param object	$context	The context object for the site
  *
  * @return string	A template name
  */
 public function handle($context)
 {
     $data = R::find('file', 'category = "data"');
     // Refine search result if the user searches in the text box
     $searchText = $context->mustpostpar('data_search_text', '');
     if (!empty($searchText)) {
         $searchText = '%' . $searchText . '%';
         $data = R::find('file', 'category like ? and name like ?', ["data", $searchText]);
     }
     $context->local()->addval('data', $data);
     return 'data.twig';
 }
开发者ID:Milwyr,项目名称:University-Publication-Website,代码行数:19,代码来源:data.php


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