Skip to content

Commit

Permalink
added "updateMethod" config option
Browse files Browse the repository at this point in the history
  • Loading branch information
simialbi committed Jun 10, 2021
1 parent 082f453 commit c8e57a1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,13 @@ public function insert($model, $columns)
*/
public function update($model, $data = [], $id = null)
{
$method = $this->db->updateMethod;
$this->pathInfo = $model;
if ($id) {
$this->pathInfo .= '/' . $id;
}

return $this->db->put($this->pathInfo, $data);
return $this->db->$method($this->pathInfo, $data);
}

/**
Expand Down
17 changes: 17 additions & 0 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,38 +42,52 @@ class Connection extends Component
* @event Event an event that is triggered after a DB connection is established
*/
const EVENT_AFTER_OPEN = 'afterOpen';

/**
* @var Client
*/
protected static $_handler = null;

/**
* @var string base request URL.
*/
public $baseUrl = '';

/**
* @var array request object configuration.
*/
public $requestConfig = [];

/**
* @var array response config configuration.
*/
public $responseConfig = [];

/**
* @var boolean Whether to use pluralisation or not
*/
public $usePluralisation = true;

/**
* @var boolean Whether to use filter keyword or not
*/
public $useFilterKeyword = true;

/**
* @var boolean Whether the connection should throw an exception if response is not 200 or not
*/
public $enableExceptions = false;

/**
* @var string The method to use for update operations. Defaults to [[put]].
*/
public $updateMethod = 'put';

/**
* @var boolean Whether we are in test mode or not (prevent execution)
*/
public $isTestMode = false;

/**
* @var bool whether to enable query caching.
* Note that in order to enable query caching, a valid cache component as specified
Expand All @@ -84,6 +98,7 @@ class Connection extends Component
* @see noCache()
*/
public $enableQueryCache = false;

/**
* @var int the default number of seconds that query results can remain valid in cache.
* Defaults to 3600, meaning 3600 seconds, or one hour. Use 0 to indicate that the cached data will never expire.
Expand All @@ -92,12 +107,14 @@ class Connection extends Component
* @see cache()
*/
public $queryCacheDuration = 3600;

/**
* @var CacheInterface|string the cache object or the ID of the cache application component
* that is used for query caching.
* @see enableQueryCache
*/
public $queryCache = 'cache';

/**
* @var string|null the name of the property in the response where the items are wrapped. If not set, there is no
* wrapping property.
Expand Down

0 comments on commit c8e57a1

Please sign in to comment.