Total Complexity | 4 |
Total Lines | 69 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
13 | class Model extends \CI_Model |
||
14 | { |
||
15 | use Traits\CredoTrait; |
||
16 | |||
17 | /** |
||
18 | * Deletes the specified ID of the model from the database. |
||
19 | * |
||
20 | * @param integer $id |
||
21 | * @return void |
||
22 | */ |
||
23 | 2 | public function delete($id) |
|
30 | 2 | } |
|
31 | |||
32 | /** |
||
33 | * Inserts a new row into the table. |
||
34 | * |
||
35 | * @param array $data |
||
36 | * @return integer |
||
37 | */ |
||
38 | 2 | public function insert(array $data) |
|
39 | { |
||
40 | 2 | $metadata = $this->metadata((string) get_class($this)); |
|
41 | |||
42 | 2 | $this->db->insert($metadata->getTableName(), $data); |
|
|
|||
43 | |||
44 | 2 | $item = $this->find($lastId = $this->db->insert_id()); |
|
45 | |||
46 | 2 | $this->credo->refresh($item); |
|
47 | |||
48 | 2 | return $lastId; |
|
49 | } |
||
50 | |||
51 | /** |
||
52 | * Updates the selected row from the table. |
||
53 | * |
||
54 | * @param integer $id |
||
55 | * @param array $data |
||
56 | * @return boolean |
||
57 | */ |
||
58 | 2 | public function update($id, array $data) |
|
71 | } |
||
72 | |||
73 | /** |
||
74 | * Returns the metadata of an entity. |
||
75 | * |
||
76 | * @param string $class |
||
77 | * @return \Doctrine\Common\Persistence\Mapping\ClassMetadata |
||
78 | */ |
||
79 | 4 | protected function metadata($class) |
|
84 |