@param       $id
@param       $record
@param array $params

@return array|mixed
@throws \DreamFactory\Core\Exceptions\BadRequestException
@throws \Exception
771703
public static function updateById($id, array $record, array $params = [])
    {
        $m = new static;
        $pk = $m->getPrimaryKey();
        $record[$pk] = $id;

        try {
            $response = static::bulkUpdate([$record], $params);

            return current($response);
        } catch (BatchException $ex) {
            $response = $ex->pickResponse(0);
            if ($response instanceof \Exception) {
                throw $response;
            }

            return $response;
        } catch (\Exception $ex) {
            throw new InternalServerErrorException($ex->getMessage());
        }
    }
1331371
public function get($id, $params = null)
    {
        $id = (int)$id;
        if ($id <= 0) {
            throw new Exception('Invalid param id');
        }
        return $this->rest->get("$this->action/$id", $params);
    }
443744
public function tryLoad($id)
    {
        if (is_null($id)) {
            throw $this->exception('Record ID must be specified, otherwise use loadAny()');
        }

        return $this->_load($id, true);
    }
375435
public function getEntities($id, array $params = array())
    {
        return $this->get($this->path.'/'.rawurlencode($id).'/entities', $params);
    }
680108
public static function deleteInternal($id, $record, $params = [])
    {
        if (empty($record)) {
            throw new BadRequestException('There are no fields in the record to create . ');
        }

        if (empty($id)) {
            //Todo:perform logging below
            //Log::error( 'Update request with no id supplied: ' . print_r( $record, true ) );
            throw new BadRequestException('Identifying field "id" can not be empty for update request . ');
        }

        $model = static::find($id);

        if (!$model instanceof Model) {
            throw new NotFoundException("Record with identifier '$id' not found.");
        }

        try {
            $result = static::buildResult($model, $params);
            $model->delete();

            return $result;
        } catch (\Exception $ex) {
            throw new InternalServerErrorException('Failed to delete resource: ' . $ex->getMessage());
        }
    }
222560
public static function createById($id, $record, $params = [])
    {
        $m = new static;
        $pk = $m->getPrimaryKey();
        $record[$pk] = $id;

        try {
            $response = static::bulkCreate([$record], $params);

            return current($response);
        } catch (BatchException $ex) {
            $response = $ex->pickResponse(0);
            if ($response instanceof \Exception) {
                throw $response;
            }

            return $response;
        } catch (\Exception $ex) {
            throw new InternalServerErrorException($ex->getMessage());
        }
    }
921809
public function get_document($record, $options = array()) {
        try {
            $cm = $this->get_cm('book', $record->bookid, $record->courseid);
            $context = \context_module::instance($cm->id);
        } catch (\dml_missing_record_exception $ex) {
            // Notify it as we run here as admin, we should see everything.
            debugging('Error retrieving ' . $this->areaid . ' ' . $record->id . ' document, not all required data is available: ' .
                $ex->getMessage(), DEBUG_DEVELOPER);
            return false;
        } catch (\dml_exception $ex) {
            // Notify it as we run here as admin, we should see everything.
            debugging('Error retrieving ' . $this->areaid . ' ' . $record->id . ' document: ' . $ex->getMessage(), DEBUG_DEVELOPER);
            return false;
        }

        // Prepare associative array with data from DB.
        $doc = \core_search\document_factory::instance($record->id, $this->componentname, $this->areaname);
        $doc->set('title', content_to_text($record->title, false));
        $doc->set('content', content_to_text($record->content, $record->contentformat));
        $doc->set('contextid', $context->id);
        $doc->set('courseid', $record->courseid);
        $doc->set('owneruserid', \core_search\manager::NO_OWNER_ID);
        $doc->set('modified', $record->timemodified);

        // Check if this document should be considered new.
        if (isset($options['lastindexedtime']) && ($options['lastindexedtime'] < $record->timecreated)) {
            // If the document was created after the last index time, it must be new.
            $doc->set_is_new(true);
        }

        return $doc;
    }
394983
public function request($id, $method, array $params = null)
    {
        return $this->createRequest(RequestInterface::REQUEST, array_filter([
            'jsonrpc' => self::SPEC,
            'method' => $method,
            'params' => $params,
            'id' => $id,
        ]));
    }
24789
private function _getTokenRecordById($id = null)
    {
        if ($id)
        {
            $record = Oauth_TokenRecord::model()->findById($id);

            if (!$record)
            {
                throw new Exception(Craft::t('No oauth token exists with the ID “{id}”', array('id' => $id)));
            }
        }
        else
        {
            $record = new Oauth_TokenRecord();
        }

        return $record;
    }
934871
public function setQueryParams($id, $params = [])
    {
        $requestQuery = $this->request->query->get('query_id');
        
        if(isset($requestQuery[$id])) {
            $paramsQuery = $requestQuery[$id];
        } elseif(isset($params['query'])) {
            $paramsQuery = $params['query'];
        } else {
            $paramsQuery = [];
        }
        
        $query = array_merge([
            'limit' => null,
            'offset' => null,
            'orderby' => null,
            'order' => null
        ], $paramsQuery);
        
        if($query['offset'] !== null && $query['offset'] >= $this->paramDefaults['offset']) {
            $this->qb->setFirstResult($query['offset']);
        }
        
        if($query['limit'] !== null && $query['limit'] >= $this->paramDefaults['limit']) {
            $this->qb->setMaxResults($query['limit']);
        }
        
        if(in_array($query['orderby'], $this->paramDefaults['orderby'])) {
            $order = in_array(strtoupper($query['order']), $this->paramDefaults['order']) ? $query['order'] : $this->paramDefaults['order'][0];

            $this->qb->orderBy('a.'.Inflector::camelize($query['orderby']), strtoupper($order));
        }
    }
729269
protected function handlePOST()
    {
        /** @var BaseSystemModel $modelClass */
        $modelClass = static::$model;

        if (!empty($this->resource)) {
            throw new BadRequestException('Create record by identifier not currently supported.');
        }

        $records = ResourcesWrapper::unwrapResources($this->getPayloadData());
        if (empty($records)) {
            throw new BadRequestException('No record(s) detected in request.' . ResourcesWrapper::getWrapperMsg());
        }

        $result = $modelClass::bulkCreate($records, $this->request->getParameters());

        $asList = $this->request->getParameterAsBool(ApiOptions::AS_LIST);
        $idField = $this->request->getParameter(ApiOptions::ID_FIELD, static::getResourceIdentifier());
        $result = ResourcesWrapper::cleanResources($result, $asList, $idField, ApiOptions::FIELDS_ALL);

        return ResponseFactory::create($result, null, ServiceResponseInterface::HTTP_CREATED);
    }
1186548
protected function extractID($record)
    {
        // Normalize to string:
        $id = (string)$record->header->identifier;

        // Strip prefix if found:
        if (substr($id, 0, strlen($this->idPrefix)) == $this->idPrefix) {
            $id = substr($id, strlen($this->idPrefix));
        }

        // Apply regular expression matching:
        if (!empty($this->idSearch)) {
            $id = preg_replace($this->idSearch, $this->idReplace, $id);
        }

        // Return final value:
        return $id;
    }
216864
public static function findOrFail($id, array $params = [])
    {
        $instance = new static([], static::getParentID());

        // Make request
        if (!is_null($result = $instance->request($instance->getEndpoint(), 'find', [$id, $params]))) {
            return $result;
        }

        // Not found
        throw new NotFoundException;
    }
436477
public function getBoard($id, array $params = array())
    {
        return $this->get($this->getPath().'/'.rawurlencode($id).'/board', $params);
    }
879668
public function getList($id, array $params = array())
    {
        return $this->get($this->getPath().'/'.rawurlencode($id).'/list', $params);
    }
94865
public function connect($id, array $params)
    {
        $returnValue = null;
        $this->params = $params;
        $driver = $params['driver'];
        $dbLogin = $params['user'];
        $dbpass = $params['password'];
        //remove pdo to add UpperCase ClassName

    		$connLimit = 3; // Max connection attempts.
            $counter = 0; // Connection attemps counter.
    		
            while (true){
                $dsn = $this->getDSN();
                $options = array(PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_BOTH,
                    PDO::ATTR_PERSISTENT => false,
                    PDO::ATTR_EMULATE_PREPARES => false);
                
                 
                foreach ($this->getExtraConfiguration() as $k => $v){
                    $options[$k] = $v;
                }
                
                try{
                    $this->dbConnector = @new PDO($dsn, $dbLogin, $dbpass, $options);
                    $this->afterConnect();
                   
                   
                    // We are connected. Get out of the loop.
                    break;
                }
                catch (PDOException $e){
                    $this->dbConnector = null;
                    $counter++;
                
                    if ($counter == $connLimit){
                        // Connection attempts exceeded.
                        throw $e;
                    }
                }
            }
            
            $returnValue =  new common_persistence_SqlPersistence($params,$this);;

        return $returnValue;
    }
1222840
protected function _parseParams(array $params, \Mmi\Orm\RecordRo $record)
    {
        //inicjalizacja parametrów
        $parsedParams = [];
        $matches = [];
        //iteracja po parametrach
        foreach ($params as $key => $param) {
            //parametr %pole%
            if (preg_match('/%([a-zA-Z]+)%/', $param, $matches)) {
                $parsedParams[$key] = $record->{$matches[1]};
                continue;
            }
            //w pozostałych przypadkach przepisanie parametru
            $parsedParams[$key] = $param;
        }
        return $parsedParams;
    }