@@ -212,18 +212,25 @@ public function count($table, string $field = '')
212
212
}
213
213
214
214
/**
215
- * @param int| string $column
215
+ * @param string $column
216
216
* @return $this|string|array
217
217
*/
218
- public function column ($ column = 0 )
218
+ public function column (string $ column = ' id ' )
219
219
{
220
- if (is_integer ( $ column ) or is_string ($ column )) {
220
+ if (! is_string ($ column )) {
221
221
$ this ->setError ('Incorrect type of $column in ' . __METHOD__ );
222
222
return $ this ;
223
223
}
224
224
225
- $ this ->query ('' , [], $ column , self ::FETCH_COLUMN );
226
- return $ this ->result ;
225
+ if (empty ($ column )) {
226
+ $ this ->setError ('Empty $column in ' . __METHOD__ );
227
+ return $ this ;
228
+ }
229
+
230
+ $ this ->query ();
231
+ return array_column ($ this ->result , $ column );
232
+ //$this->query('', [], $column, self::FETCH_COLUMN);
233
+ //return $this->result;
227
234
}
228
235
229
236
/**
@@ -236,17 +243,22 @@ public function exists(): bool
236
243
}
237
244
238
245
/**
239
- * @param string|int $key
240
- * @param string|int $column
246
+ * @param string $key
247
+ * @param string $column
241
248
* @return array|QueryBuilder
242
249
*/
243
- public function pluck ($ key = 0 , $ column = 1 ): array
250
+ public function pluck (string $ key = ' id ' , string $ column = '' )
244
251
{
245
- if (( is_integer ( $ key ) or is_integer ( $ column )) or ( is_string ($ key ) or is_string ($ column ))) {
252
+ if (!( is_string ($ key ) and is_string ($ column ))) {
246
253
$ this ->setError ('Incorrect type of $key or $column in ' . __METHOD__ );
247
254
return $ this ;
248
255
}
249
256
257
+ if (empty ($ column )) {
258
+ $ this ->setError ('Empty $column in ' . __METHOD__ );
259
+ return $ this ;
260
+ }
261
+
250
262
$ this ->query ();
251
263
return array_column ($ this ->result , $ column , $ key );
252
264
}
0 commit comments