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


PHP R::exec方法代码示例

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


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

示例1: moveTo

 public function moveTo($id, $position)
 {
     $item = R::findOne($this->table, 'id=?', [$this->id]);
     $desItem = R::findOne($this->table, 'id=?', [$id]);
     $itemOrder = $item->sort_order;
     $destOrder = $desItem->sort_order;
     $item->sort_order = $destOrder;
     $op = $itemOrder < $destOrder ? "-" : "+";
     if ($itemOrder < $destOrder) {
         $op = "-";
         $execParam = [$itemOrder, $destOrder];
     } else {
         $op = "+";
         $execParam = [$destOrder, $itemOrder];
     }
     // if($op == "-" && $position == "before") $destOrder--;
     // if($op == "+" && $position == "after") $destOrder++;
     $query = "UPDATE {$this->table} SET sort_order = sort_order {$op} 1";
     $query .= " WHERE (sort_order BETWEEN ? AND ?) AND id != ?";
     $execParam[] = $this->id;
     if ($op == "-" && $position == "before" || $op == "+" && $position == "after") {
         $query .= " AND id != ?";
         $execParam[] = $id;
         $destOrder2 = $op == "-" && $position == "before" ? $destOrder - 1 : $destOrder + 1;
     } else {
         $destOrder2 = $destOrder;
     }
     R::exec($query, $execParam);
     $item->sort_order = $destOrder2;
     R::store($item);
     $this->makeUnique();
     return true;
 }
开发者ID:nuiz,项目名称:duragres,代码行数:33,代码来源:ECatalogMoveForm.php

示例2: replace

 public function replace($content = '')
 {
     if (empty($this->name)) {
         throw new Exception('Page needs name before it can be saved');
     }
     $userBean = Enpowi\App::user()->bean();
     R::exec('UPDATE page SET is_revision = 1 WHERE name = ? and is_revision = 0', [$this->name]);
     $oldBean = $this->_bean;
     $originalUserBean = $userBean;
     //TODO: ensure createdBy is set once and contributors is an incremental list
     $bean = R::dispense('page');
     $bean->name = $this->name;
     $bean->content = $content;
     $bean->created = R::isoDateTime();
     $bean->user = $originalUserBean;
     $bean->isRevision = false;
     if ($oldBean !== null) {
         $bean->sharedUser = $oldBean->sharedUser;
     }
     $bean->sharedUser[] = $userBean;
     R::store($bean);
     return new Page($this->name, $bean);
 }
开发者ID:Koohiisan,项目名称:Enpowi,代码行数:23,代码来源:Page.php

示例3: function

$app->post('/boards/remove', function () use($app, $jsonResponse) {
    $data = json_decode($app->environment['slim.input']);
    if (validateToken(true)) {
        $board = R::load('board', $data->boardId);
        if ($board->id == $data->boardId) {
            $before = $board->export();
            foreach ($board->sharedUser as $user) {
                if ($user->defaultBoard == $data->boardId) {
                    $user->defaultBoard = null;
                    R::store($user);
                }
            }
            R::trashAll($board->xownLane);
            R::trashAll($board->xownCategory);
            R::trash($board);
            R::exec('DELETE from board_user WHERE board_id = ?', [$data->boardId]);
            $jsonResponse->addAlert('success', 'Removed board ' . $board->name . '.');
            $actor = getUser();
            logAction($actor->username . ' removed board ' . $board->name, $before, null);
        }
        $jsonResponse->addBeans(getBoards());
        $jsonResponse->users = R::exportAll(getUsers());
    }
    $app->response->setBody($jsonResponse->asJson());
});
$app->post('/autoactions', function () use($app, $jsonResponse) {
    $data = json_decode($app->environment['slim.input']);
    if (validateToken(true)) {
        $board = R::load('board', $data->boardId);
        if ($board->id) {
            $autoAction = R::dispense('autoaction');
开发者ID:BIGGANI,项目名称:TaskBoard,代码行数:31,代码来源:boardRoutes.php

示例4: destroy

 public function destroy($id)
 {
     R::exec('DELETE
 			FROM `passwordResets`
 		WHERE `passwordResets`.`id` = :id', [':id' => $id]);
 }
开发者ID:aodkrisda,项目名称:slim3-api,代码行数:6,代码来源:PasswordResets.php

示例5: addRoomUse

 public function addRoomUse()
 {
     $productId = $this->slim->request->post()['product_id'];
     $roomName = $this->slim->request->post()['room_name'];
     $item = R::findOne('product', 'id=?', [$productId]);
     if (!$item) {
         header('Content-Type: application/json');
         echo json_encode(['error' => 'NOT_FOUND_PRODUCT'], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
         exit;
     }
     $dateStr = date('Y-m-d');
     $productView = R::getRow('SELECT * FROM product_room WHERE product_id=? AND room_name=? AND view_date=?', [$productId, $roomName, $dateStr]);
     if (!$productView) {
         R::exec('INSERT INTO product_room SET product_id=?, room_name=? , view_date=?', [$productId, $roomName, $dateStr]);
     }
     R::exec('UPDATE product_room SET view_count = view_count+1 WHERE product_id=? AND room_name=? AND view_date=?', [$productId, $roomName, $dateStr]);
     header('Content-Type: application/json');
     echo json_encode(['successs' => true], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
     exit;
 }
开发者ID:nuiz,项目名称:duragres,代码行数:20,代码来源:ApiProductController.php

示例6: alter

 /**
  */
 function alter()
 {
     return;
     R::freeze(true);
     R::exec('ALTER TABLE `quiz_user` ADD `session` VARCHAR(191)  NULL  DEFAULT NULL;');
 }
开发者ID:mattimatti,项目名称:fbconnectquiz,代码行数:8,代码来源:QuizService.php

示例7: execQuery

 /**
  * @param $sql
  * @param $params
  * @return array|int
  */
 private function execQuery($sql, $params)
 {
     return strtolower(substr($sql, 0, 6)) === 'select' ? new IteratorResult(R::getAll($sql, $params), 'redbean') : R::exec($sql, $params);
 }
开发者ID:jetfirephp,项目名称:db,代码行数:9,代码来源:RedBeanModel.php

示例8: productAddStat

 public function productAddStat($productId)
 {
     $dateStr = date('Y-m-d');
     $productView = R::getRow('SELECT * FROM product_add WHERE product_id=? AND add_date=?', [$productId, $dateStr]);
     if (!$productView) {
         R::exec('INSERT INTO product_add SET product_id=?, add_date=?', [$productId, $dateStr]);
     }
     R::exec('UPDATE product_add SET add_count = add_count+1 WHERE product_id=? AND add_date=?', [$productId, $dateStr]);
     header('Content-Type: application/json');
     echo json_encode(['success' => true], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
     exit;
 }
开发者ID:nuiz,项目名称:duragres,代码行数:12,代码来源:ApiAccountController.php

示例9: delete

 public function delete($id)
 {
     $item = R::findOne('product', 'id=?', [$id]);
     R::trash($item);
     R::exec('DELETE FROM account_product WHERE product_id = ?', [$id]);
     @unlink('upload/' . $item['picture']);
     // @unlink('upload/'.$item['thumb']);
     $this->slim->redirect($this->slim->request()->getRootUri() . '/product');
 }
开发者ID:nuiz,项目名称:duragres,代码行数:9,代码来源:ProductController.php

示例10: saveBean

 /**
  * Insert or Update a bean
  *
  * @param OODBBean $bean
  * @param $data array
  * @return Result
  */
 private function saveBean($bean, $data)
 {
     // Handle File Field that may not in the $data, because Filename always go into $_FILES.
     foreach ($_FILES as $fieldName => $file) {
         $data[$fieldName] = $file["name"];
     }
     // Store Showing fields only
     $fields = $this->getShowFields();
     foreach ($fields as $field) {
         // Check is unique
         if ($field->isUnique()) {
             // Try to find duplicate beans
             $fieldName = $field->getName();
             $duplicateBeans = R::find($bean->getMeta('type'), " {$fieldName} = ? ", [$data[$field->getName()]]);
             if (count($duplicateBeans) > 0) {
                 $validateResult = "Email 已存在!";
             }
         }
         if ($field->getFieldRelation() == Field::MANY_TO_MANY) {
             // 1. Many to many
             // http://www.redbeanphp.com/many_to_many
             $keyName = "shared" . ucfirst($field->getName()) . "List";
             // Clear the current list (tableB_tableA)
             try {
                 $tableName = $this->getTableName() . "_" . $field->getName();
                 $idName = $this->getTableName() . "_id";
                 R::exec("DELETE FROM {$tableName} WHERE {$idName} = ?", [$bean->id]);
             } catch (\Exception $ex) {
             }
             // Clear the current list (tableA_tableB)
             try {
                 $tableName = $field->getName() . "_" . $this->getTableName();
                 $idName = $this->getTableName() . "_id";
                 R::exec("DELETE FROM {$tableName} WHERE {$idName} = ?", [$bean->id]);
             } catch (\Exception $ex) {
             }
             // If User have checked a value in checkbox
             if (isset($data[$field->getName()])) {
                 $valueList = $data[$field->getName()];
                 $slots = R::genSlots($valueList);
                 $relatedBeans = R::find($field->getName(), " id IN ({$slots})", $valueList);
                 foreach ($relatedBeans as $relatedBean) {
                     $bean->{$keyName}[] = $relatedBean;
                 }
             }
         } else {
             if ($field->getFieldRelation() == Field::ONE_TO_MANY) {
                 // TODO One to many
             } else {
                 if (!$field->isStorable()) {
                     // 2. If not storable, skip
                     continue;
                 } elseif ($field->getFieldRelation() == Field::NORMAL) {
                     // 3.Normal data field
                     $value = $field->getStoreValue($data);
                     if ($value == LouisCRUD::NULL) {
                         $value = null;
                     }
                     // Validate the value
                     if ($field->isStorable()) {
                         $validateResult = $field->validate($value, $data);
                     } else {
                         // TODO: check non-storable?
                         $validateResult = true;
                     }
                     // If validate failed, return result object.
                     if ($validateResult !== true) {
                         $result = new Result();
                         $result->id = @$bean->id;
                         $result->msg = $validateResult;
                         $result->fieldName = $field->getName();
                         $result->class = "callout-danger";
                         return $result;
                     }
                     // Set the value to the current bean directly
                     $bean->{$field->getName()} = $value;
                 }
             }
         }
     }
     // Store
     // TODO: Return result object
     $id = R::store($bean);
     $result = new Result();
     $result->id = $id;
     return $result;
 }
开发者ID:louislam,项目名称:louislam-crud,代码行数:94,代码来源:LouisCRUD.php

示例11: addUserToBoard

            R::store($user);
            addUserToBoard($data->defaultBoard, $user);
            foreach ($data->boardAccess as $board) {
                addUserToBoard($board, $user);
            }
            logAction($actor->username . ' updated user ' . $user->username, $before, $user->export());
            $jsonResponse->addAlert('success', 'User updated.');
        }
        $jsonResponse->addBeans(getUsers());
        $jsonResponse->boards = R::exportAll(getBoards());
    }
    $app->response->setBody($jsonResponse->asJson());
});
// Remove a user.
$app->post('/users/remove', function () use($app, $jsonResponse) {
    $data = json_decode($app->environment['slim.input']);
    if (validateToken(true)) {
        $user = R::load('user', $data->userId);
        $actor = getUser();
        if ($user->id == $data->userId && $actor->isAdmin) {
            $before = $user->export();
            R::trash($user);
            R::exec('DELETE from board_user WHERE user_id = ?', [$data->userId]);
            logAction($actor->username . ' removed user ' . $before['username'], $before, null);
            $jsonResponse->addAlert('success', 'Removed user ' . $user->username . '.');
        }
        $jsonResponse->addBeans(getUsers());
        $jsonResponse->boards = R::exportAll(getBoards());
    }
    $app->response->setBody($jsonResponse->asJson());
});
开发者ID:BIGGANI,项目名称:TaskBoard,代码行数:31,代码来源:userRoutes.php


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