| @@ 44-57 (lines=14) @@ | ||
| 41 | /** |
|
| 42 | * {@inheritdoc} |
|
| 43 | */ |
|
| 44 | public function create() |
|
| 45 | { |
|
| 46 | try { |
|
| 47 | (new Query($this->getPdo(), $this->getActiveRecordTable())) |
|
| 48 | ->insert($this->getActiveRecordColumns()) |
|
| 49 | ->execute(); |
|
| 50 | ||
| 51 | $this->setId(intval($this->getPdo()->lastInsertId())); |
|
| 52 | } catch (\PDOException $e) { |
|
| 53 | throw new ActiveRecordException($e->getMessage(), 0, $e); |
|
| 54 | } |
|
| 55 | ||
| 56 | return $this; |
|
| 57 | } |
|
| 58 | ||
| 59 | /** |
|
| 60 | * {@inheritdoc} |
|
| @@ 86-98 (lines=13) @@ | ||
| 83 | /** |
|
| 84 | * {@inheritdoc} |
|
| 85 | */ |
|
| 86 | public function update() |
|
| 87 | { |
|
| 88 | try { |
|
| 89 | (new Query($this->getPdo(), $this->getActiveRecordTable())) |
|
| 90 | ->update($this->getActiveRecordColumns()) |
|
| 91 | ->where('id', '=', $this->getId()) |
|
| 92 | ->execute(); |
|
| 93 | } catch (\PDOException $e) { |
|
| 94 | throw new ActiveRecordException($e->getMessage(), 0, $e); |
|
| 95 | } |
|
| 96 | ||
| 97 | return $this; |
|
| 98 | } |
|
| 99 | ||
| 100 | /** |
|
| 101 | * {@inheritdoc} |
|
| @@ 103-117 (lines=15) @@ | ||
| 100 | /** |
|
| 101 | * {@inheritdoc} |
|
| 102 | */ |
|
| 103 | public function delete() |
|
| 104 | { |
|
| 105 | try { |
|
| 106 | (new Query($this->getPdo(), $this->getActiveRecordTable())) |
|
| 107 | ->delete() |
|
| 108 | ->where('id', '=', $this->getId()) |
|
| 109 | ->execute(); |
|
| 110 | ||
| 111 | $this->setId(null); |
|
| 112 | } catch (\PDOException $e) { |
|
| 113 | throw new ActiveRecordException($e->getMessage(), 0, $e); |
|
| 114 | } |
|
| 115 | ||
| 116 | return $this; |
|
| 117 | } |
|
| 118 | ||
| 119 | /** |
|
| 120 | * {@inheritdoc} |
|