| @@ 284-307 (lines=24) @@ | ||
| 281 | * otherwise return "false". |
|
| 282 | * </p> |
|
| 283 | */ |
|
| 284 | public function fetch($id = null) |
|
| 285 | { |
|
| 286 | if ($id) { |
|
| 287 | $this->reset()->eq($this->primaryKeyName, $id); |
|
| 288 | } |
|
| 289 | ||
| 290 | return self::query( |
|
| 291 | $this->limit(1)->_buildSql( |
|
| 292 | [ |
|
| 293 | 'select', |
|
| 294 | 'from', |
|
| 295 | 'join', |
|
| 296 | 'where', |
|
| 297 | 'group', |
|
| 298 | 'having', |
|
| 299 | 'order', |
|
| 300 | 'limit', |
|
| 301 | ] |
|
| 302 | ), |
|
| 303 | $this->params, |
|
| 304 | $this->reset(), |
|
| 305 | true |
|
| 306 | ); |
|
| 307 | } |
|
| 308 | ||
| 309 | /** |
|
| 310 | * @param string $query |
|
| @@ 452-474 (lines=23) @@ | ||
| 449 | * |
|
| 450 | * @return $this[] |
|
| 451 | */ |
|
| 452 | public function fetchAll(array $ids = null): array |
|
| 453 | { |
|
| 454 | if ($ids) { |
|
| 455 | $this->reset()->in($this->primaryKeyName, $ids); |
|
| 456 | } |
|
| 457 | ||
| 458 | return self::query( |
|
| 459 | $this->_buildSql( |
|
| 460 | [ |
|
| 461 | 'select', |
|
| 462 | 'from', |
|
| 463 | 'join', |
|
| 464 | 'where', |
|
| 465 | 'groupBy', |
|
| 466 | 'having', |
|
| 467 | 'orderBy', |
|
| 468 | 'limit', |
|
| 469 | ] |
|
| 470 | ), |
|
| 471 | $this->params, |
|
| 472 | $this->reset() |
|
| 473 | ); |
|
| 474 | } |
|
| 475 | ||
| 476 | /** |
|
| 477 | * Function to delete current record in database. |
|