Skip to content

Commit c8e57a1

Browse files
author
simialbi
committed
added "updateMethod" config option
1 parent 082f453 commit c8e57a1

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/Command.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,13 @@ public function insert($model, $columns)
171171
*/
172172
public function update($model, $data = [], $id = null)
173173
{
174+
$method = $this->db->updateMethod;
174175
$this->pathInfo = $model;
175176
if ($id) {
176177
$this->pathInfo .= '/' . $id;
177178
}
178179

179-
return $this->db->put($this->pathInfo, $data);
180+
return $this->db->$method($this->pathInfo, $data);
180181
}
181182

182183
/**

src/Connection.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,38 +42,52 @@ class Connection extends Component
4242
* @event Event an event that is triggered after a DB connection is established
4343
*/
4444
const EVENT_AFTER_OPEN = 'afterOpen';
45+
4546
/**
4647
* @var Client
4748
*/
4849
protected static $_handler = null;
50+
4951
/**
5052
* @var string base request URL.
5153
*/
5254
public $baseUrl = '';
55+
5356
/**
5457
* @var array request object configuration.
5558
*/
5659
public $requestConfig = [];
60+
5761
/**
5862
* @var array response config configuration.
5963
*/
6064
public $responseConfig = [];
65+
6166
/**
6267
* @var boolean Whether to use pluralisation or not
6368
*/
6469
public $usePluralisation = true;
70+
6571
/**
6672
* @var boolean Whether to use filter keyword or not
6773
*/
6874
public $useFilterKeyword = true;
75+
6976
/**
7077
* @var boolean Whether the connection should throw an exception if response is not 200 or not
7178
*/
7279
public $enableExceptions = false;
80+
81+
/**
82+
* @var string The method to use for update operations. Defaults to [[put]].
83+
*/
84+
public $updateMethod = 'put';
85+
7386
/**
7487
* @var boolean Whether we are in test mode or not (prevent execution)
7588
*/
7689
public $isTestMode = false;
90+
7791
/**
7892
* @var bool whether to enable query caching.
7993
* Note that in order to enable query caching, a valid cache component as specified
@@ -84,6 +98,7 @@ class Connection extends Component
8498
* @see noCache()
8599
*/
86100
public $enableQueryCache = false;
101+
87102
/**
88103
* @var int the default number of seconds that query results can remain valid in cache.
89104
* Defaults to 3600, meaning 3600 seconds, or one hour. Use 0 to indicate that the cached data will never expire.
@@ -92,12 +107,14 @@ class Connection extends Component
92107
* @see cache()
93108
*/
94109
public $queryCacheDuration = 3600;
110+
95111
/**
96112
* @var CacheInterface|string the cache object or the ID of the cache application component
97113
* that is used for query caching.
98114
* @see enableQueryCache
99115
*/
100116
public $queryCache = 'cache';
117+
101118
/**
102119
* @var string|null the name of the property in the response where the items are wrapped. If not set, there is no
103120
* wrapping property.

0 commit comments

Comments
 (0)