@@ -12,7 +12,7 @@ |
||
12 | 12 | * @return void |
13 | 13 | */ |
14 | 14 | spl_autoload_register( |
15 | - function ($class) { |
|
15 | + function($class) { |
|
16 | 16 | |
17 | 17 | // project-specific namespace prefix |
18 | 18 | //$prefix = 'Foo\\Bar\\'; |
@@ -7,10 +7,10 @@ discard block |
||
7 | 7 | class Movie extends \Jovis\DatabaseModel\CDatabaseModel |
8 | 8 | { |
9 | 9 | |
10 | - public function init() |
|
11 | - { |
|
10 | + public function init() |
|
11 | + { |
|
12 | 12 | $this->db->dropTableIfExists('movie') |
13 | - ->execute(); |
|
13 | + ->execute(); |
|
14 | 14 | |
15 | 15 | $this->db->createTable( |
16 | 16 | 'movie', |
@@ -28,30 +28,30 @@ discard block |
||
28 | 28 | $this->db->insert( |
29 | 29 | 'movie', |
30 | 30 | ['title', 'director', 'length', 'year'] |
31 | - ); |
|
31 | + ); |
|
32 | 32 | |
33 | - $this->db->execute(['Kalles drömmar', 'Gustav Andersson', '120', '1977']); |
|
33 | + $this->db->execute(['Kalles drömmar', 'Gustav Andersson', '120', '1977']); |
|
34 | 34 | |
35 | - $this->db->insert( |
|
35 | + $this->db->insert( |
|
36 | 36 | 'movie', |
37 | 37 | ['title', 'director', 'length', 'year'] |
38 | - ); |
|
38 | + ); |
|
39 | 39 | |
40 | - $this->db->execute(['Gustavs drömmar', 'Kalle Andersson', '101', '2007']); |
|
40 | + $this->db->execute(['Gustavs drömmar', 'Kalle Andersson', '101', '2007']); |
|
41 | 41 | |
42 | - $this->db->insert( |
|
42 | + $this->db->insert( |
|
43 | 43 | 'movie', |
44 | 44 | ['title', 'director', 'length', 'year'] |
45 | - ); |
|
45 | + ); |
|
46 | 46 | |
47 | - $this->db->execute(['Mammas drömmar', 'Johanna Andersson', '25', '2010']); |
|
47 | + $this->db->execute(['Mammas drömmar', 'Johanna Andersson', '25', '2010']); |
|
48 | 48 | |
49 | - $this->db->insert( |
|
49 | + $this->db->insert( |
|
50 | 50 | 'movie', |
51 | 51 | ['title', 'director', 'length', 'year'] |
52 | - ); |
|
52 | + ); |
|
53 | 53 | |
54 | - $this->db->execute(['Goda kakor', 'Hannes Andersson', '110', '1954']); |
|
54 | + $this->db->execute(['Goda kakor', 'Hannes Andersson', '110', '1954']); |
|
55 | 55 | |
56 | - } |
|
56 | + } |
|
57 | 57 | } |
@@ -6,12 +6,12 @@ discard block |
||
6 | 6 | * |
7 | 7 | */ |
8 | 8 | |
9 | -class CHTMLTable{ |
|
9 | +class CHTMLTable { |
|
10 | 10 | |
11 | 11 | private $data; |
12 | 12 | |
13 | 13 | //tar emot en headline som enkel array och data som tvådimensionell array |
14 | - public function __construct($headline, $data){ |
|
14 | + public function __construct($headline, $data) { |
|
15 | 15 | $this->data = $data; |
16 | 16 | $this->headline = $headline; |
17 | 17 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * @return string $html, sträng innehållande en tabell |
25 | 25 | */ |
26 | 26 | |
27 | - public function getTable(){ |
|
27 | + public function getTable() { |
|
28 | 28 | |
29 | 29 | $table = ""; |
30 | 30 | |
@@ -32,19 +32,19 @@ discard block |
||
32 | 32 | <table class> |
33 | 33 | <tr class='rows'>"; |
34 | 34 | |
35 | - foreach($this->headline as $h) { |
|
36 | - $table.= "<th>" . $h ."</th>"; |
|
35 | + foreach ($this->headline as $h) { |
|
36 | + $table .= "<th>" . $h . "</th>"; |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | $table .= "</tr>"; |
40 | - foreach($this->data as $d){ |
|
40 | + foreach ($this->data as $d) { |
|
41 | 41 | $table .= "<tr>"; |
42 | 42 | foreach ($d as $v) { |
43 | 43 | $table .= "<td>$v</td>"; |
44 | 44 | } |
45 | 45 | $table .= "</tr>"; |
46 | 46 | } |
47 | - $table .="</table></div>"; |
|
47 | + $table .= "</table></div>"; |
|
48 | 48 | |
49 | 49 | return $table; |
50 | 50 | } |
@@ -8,43 +8,43 @@ |
||
8 | 8 | |
9 | 9 | class CHTMLTable{ |
10 | 10 | |
11 | - private $data; |
|
12 | - private $headline; |
|
11 | + private $data; |
|
12 | + private $headline; |
|
13 | 13 | |
14 | - //tar emot en headline som enkel array och data som tvådimensionell array |
|
15 | - public function __construct($headline, $data){ |
|
14 | + //tar emot en headline som enkel array och data som tvådimensionell array |
|
15 | + public function __construct($headline, $data){ |
|
16 | 16 | $this->data = $data; |
17 | 17 | $this->headline = $headline; |
18 | - } |
|
18 | + } |
|
19 | 19 | |
20 | - /** |
|
21 | - * skapar en tabell (sträng) med rubriker från den endimensionella |
|
22 | - * arrayen $headline och innehåll från |
|
23 | - * den tvådimensionella arrayen $data array |
|
24 | - * |
|
25 | - * @return string $html, sträng innehållande en tabell |
|
26 | - */ |
|
20 | + /** |
|
21 | + * skapar en tabell (sträng) med rubriker från den endimensionella |
|
22 | + * arrayen $headline och innehåll från |
|
23 | + * den tvådimensionella arrayen $data array |
|
24 | + * |
|
25 | + * @return string $html, sträng innehållande en tabell |
|
26 | + */ |
|
27 | 27 | |
28 | - public function getTable(){ |
|
28 | + public function getTable(){ |
|
29 | 29 | |
30 | 30 | $table = "<div class='dbtable'> |
31 | 31 | <table class> |
32 | 32 | <tr class='rows'>"; |
33 | 33 | |
34 | - foreach($this->headline as $h) { |
|
35 | - $table.= "<th>" . $h ."</th>"; |
|
36 | - } |
|
34 | + foreach($this->headline as $h) { |
|
35 | + $table.= "<th>" . $h ."</th>"; |
|
36 | + } |
|
37 | 37 | |
38 | - $table .= "</tr>"; |
|
39 | - foreach($this->data as $d){ |
|
40 | - $table .= "<tr>"; |
|
41 | - foreach ($d as $v) { |
|
42 | - $table .= "<td>$v</td>"; |
|
43 | - } |
|
44 | - $table .= "</tr>"; |
|
45 | - } |
|
46 | - $table .="</table></div>"; |
|
38 | + $table .= "</tr>"; |
|
39 | + foreach($this->data as $d){ |
|
40 | + $table .= "<tr>"; |
|
41 | + foreach ($d as $v) { |
|
42 | + $table .= "<td>$v</td>"; |
|
43 | + } |
|
44 | + $table .= "</tr>"; |
|
45 | + } |
|
46 | + $table .="</table></div>"; |
|
47 | 47 | |
48 | - return $table; |
|
49 | - } |
|
48 | + return $table; |
|
49 | + } |
|
50 | 50 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | |
31 | 31 | //gör om arrayen av objekt till en array av arrayer |
32 | 32 | foreach ($all as $key1=>$value) { |
33 | - foreach ($value as $key2=>$v){ |
|
33 | + foreach ($value as $key2=>$v) { |
|
34 | 34 | if (!in_array($key2, $noListing)) { //$noListing, parametrar som inte ska vara med |
35 | 35 | $aContent[$key1][$key2] = $v; |
36 | 36 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | //hittar objektens parametrar/tabellens kolumnnamn och skapar |
43 | 43 | //en ny array av rubriker |
44 | 44 | foreach ($all as $key1=>$value) { |
45 | - foreach ($value as $key2=>$v){ |
|
45 | + foreach ($value as $key2=>$v) { |
|
46 | 46 | if (!in_array($key2, $noListing)) { //$noListing, parametrar som inte ska vara med |
47 | 47 | $aHeading[] = $key2; |
48 | 48 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | ]); |
64 | 64 | } |
65 | 65 | |
66 | - public function initAction($model){ //används för att befolka databasen, bara för att testa |
|
66 | + public function initAction($model) { //används för att befolka databasen, bara för att testa |
|
67 | 67 | $model->setDI($this->di); |
68 | 68 | $model->init(); |
69 | 69 | } |
@@ -12,61 +12,61 @@ |
||
12 | 12 | |
13 | 13 | private $model; |
14 | 14 | |
15 | - /** |
|
16 | - * Lists all instances of the model, (databasetable) except for noListing. |
|
17 | - * |
|
18 | - * @param $noListing params not to be listed |
|
19 | - * @param $model model object to list (create an html table from) |
|
20 | - * |
|
21 | - * @return void |
|
22 | - */ |
|
23 | - public function listAction($noListing = NULL, $model) |
|
24 | - { |
|
15 | + /** |
|
16 | + * Lists all instances of the model, (databasetable) except for noListing. |
|
17 | + * |
|
18 | + * @param $noListing params not to be listed |
|
19 | + * @param $model model object to list (create an html table from) |
|
20 | + * |
|
21 | + * @return void |
|
22 | + */ |
|
23 | + public function listAction($noListing = NULL, $model) |
|
24 | + { |
|
25 | 25 | |
26 | - $this->model = $model; |
|
27 | - $this->model->setDI($this->di); |
|
26 | + $this->model = $model; |
|
27 | + $this->model->setDI($this->di); |
|
28 | 28 | |
29 | - $all = $this->model->findAll(); |
|
29 | + $all = $this->model->findAll(); |
|
30 | 30 | |
31 | - $aContent = array(); |
|
31 | + $aContent = array(); |
|
32 | 32 | |
33 | - //gör om arrayen av objekt till en array av arrayer |
|
34 | - foreach ($all as $key1=>$value) { |
|
33 | + //gör om arrayen av objekt till en array av arrayer |
|
34 | + foreach ($all as $key1=>$value) { |
|
35 | 35 | foreach ($value as $key2=>$v){ |
36 | - if (!in_array($key2, $noListing)) { //$noListing, parametrar som inte ska vara med |
|
37 | - $aContent[$key1][$key2] = $v; |
|
38 | - } |
|
36 | + if (!in_array($key2, $noListing)) { //$noListing, parametrar som inte ska vara med |
|
37 | + $aContent[$key1][$key2] = $v; |
|
38 | + } |
|
39 | + } |
|
39 | 40 | } |
40 | - } |
|
41 | 41 | |
42 | 42 | |
43 | - $aHeading = []; |
|
44 | - //hittar objektens parametrar/tabellens kolumnnamn och skapar |
|
45 | - //en ny array av rubriker |
|
46 | - foreach ($all as $key1=>$value) { |
|
43 | + $aHeading = []; |
|
44 | + //hittar objektens parametrar/tabellens kolumnnamn och skapar |
|
45 | + //en ny array av rubriker |
|
46 | + foreach ($all as $key1=>$value) { |
|
47 | 47 | foreach ($value as $key2=>$v){ |
48 | - if (!in_array($key2, $noListing)) { //$noListing, parametrar som inte ska vara med |
|
49 | - $aHeading[] = $key2; |
|
50 | - } |
|
48 | + if (!in_array($key2, $noListing)) { //$noListing, parametrar som inte ska vara med |
|
49 | + $aHeading[] = $key2; |
|
50 | + } |
|
51 | 51 | } |
52 | 52 | break; |
53 | - } |
|
53 | + } |
|
54 | 54 | |
55 | - $chtml = new \Jovis\HTMLTable\CHTMLTable($aHeading, $aContent); |
|
55 | + $chtml = new \Jovis\HTMLTable\CHTMLTable($aHeading, $aContent); |
|
56 | 56 | |
57 | - $htmltable = $chtml->getTable(); |
|
58 | - $source = $this->model->getSource(); |
|
57 | + $htmltable = $chtml->getTable(); |
|
58 | + $source = $this->model->getSource(); |
|
59 | 59 | |
60 | 60 | |
61 | - $this->theme->setTitle("Visa alla användare"); |
|
62 | - $this->views->add('table/list-all', [ |
|
63 | - 'title' => $source, |
|
64 | - 'htmltable' => $htmltable, |
|
65 | - ]); |
|
66 | - } |
|
61 | + $this->theme->setTitle("Visa alla användare"); |
|
62 | + $this->views->add('table/list-all', [ |
|
63 | + 'title' => $source, |
|
64 | + 'htmltable' => $htmltable, |
|
65 | + ]); |
|
66 | + } |
|
67 | 67 | |
68 | - public function initAction($model){ //används för att befolka databasen, bara för att testa |
|
68 | + public function initAction($model){ //används för att befolka databasen, bara för att testa |
|
69 | 69 | $model->setDI($this->di); |
70 | 70 | $model->init(); |
71 | - } |
|
71 | + } |
|
72 | 72 | } |
@@ -42,7 +42,7 @@ |
||
42 | 42 | ]); |
43 | 43 | |
44 | 44 | $noListing = array('password', 'Password', 'pwd'); //namn på kolumner vi inte vill ha med i tabellen |
45 | - //sin skrivs ut |
|
45 | + //sin skrivs ut |
|
46 | 46 | |
47 | 47 | |
48 | 48 |
@@ -1,12 +1,12 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -require __DIR__.'/config_with_app.php'; |
|
3 | +require __DIR__ . '/config_with_app.php'; |
|
4 | 4 | |
5 | 5 | $app->url->setUrlType(\Anax\Url\CUrl::URL_CLEAN); |
6 | 6 | |
7 | 7 | |
8 | 8 | // Create services and inject into the app. |
9 | -$di = new \Anax\DI\CDIFactoryDefault(); |
|
9 | +$di = new \Anax\DI\CDIFactoryDefault(); |
|
10 | 10 | |
11 | 11 | $di->set('TableController', function() use ($di){ |
12 | 12 | $controller = new \Jovis\HTMLTable\TableController(); |
@@ -32,10 +32,10 @@ discard block |
||
32 | 32 | |
33 | 33 | $app->theme->setTitle("HTML-tabell"); |
34 | 34 | |
35 | - $model = new Jovis\DatabaseModel\Movie(); // modellen man vill skriva ut som html-tabell |
|
35 | + $model = new Jovis\DatabaseModel\Movie(); // modellen man vill skriva ut som html-tabell |
|
36 | 36 | |
37 | 37 | |
38 | - $app->dispatcher->forward([ //används bara för att skapa tabell och befolka databasen, för test |
|
38 | + $app->dispatcher->forward([//används bara för att skapa tabell och befolka databasen, för test |
|
39 | 39 | 'controller' => 'table', |
40 | 40 | 'action' => 'init', |
41 | 41 | 'params' => [$model], |
@@ -140,7 +140,7 @@ |
||
140 | 140 | */ |
141 | 141 | public function update($values) |
142 | 142 | { |
143 | - $keys = array_keys($values); |
|
143 | + $keys = array_keys($values); |
|
144 | 144 | $values = array_values($values); |
145 | 145 | |
146 | 146 | // Its update, remove id and use as where-clause |
@@ -10,71 +10,71 @@ discard block |
||
10 | 10 | { |
11 | 11 | use \Anax\DI\TInjectable; |
12 | 12 | |
13 | - public $id; |
|
13 | + public $id; |
|
14 | 14 | |
15 | 15 | |
16 | - /** |
|
17 | - * Get the table name. |
|
18 | - * |
|
19 | - * @return string with the table name. |
|
20 | - */ |
|
21 | - public function getSource() |
|
22 | - { |
|
23 | - return strtolower(implode('', array_slice(explode('\\', get_class($this)), -1))); |
|
24 | - } |
|
16 | + /** |
|
17 | + * Get the table name. |
|
18 | + * |
|
19 | + * @return string with the table name. |
|
20 | + */ |
|
21 | + public function getSource() |
|
22 | + { |
|
23 | + return strtolower(implode('', array_slice(explode('\\', get_class($this)), -1))); |
|
24 | + } |
|
25 | 25 | |
26 | - /** |
|
27 | - * Find and return all. |
|
28 | - * |
|
29 | - * @return array |
|
30 | - */ |
|
31 | - public function findAll() |
|
32 | - { |
|
33 | - $this->db->select() |
|
34 | - ->from($this->getSource()); |
|
26 | + /** |
|
27 | + * Find and return all. |
|
28 | + * |
|
29 | + * @return array |
|
30 | + */ |
|
31 | + public function findAll() |
|
32 | + { |
|
33 | + $this->db->select() |
|
34 | + ->from($this->getSource()); |
|
35 | 35 | |
36 | - $this->db->execute(); |
|
37 | - $this->db->setFetchModeClass(__CLASS__); |
|
38 | - return $this->db->fetchAll(); |
|
39 | - } |
|
36 | + $this->db->execute(); |
|
37 | + $this->db->setFetchModeClass(__CLASS__); |
|
38 | + return $this->db->fetchAll(); |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * Get object properties. |
|
43 | - * |
|
44 | - * @return array with object properties. |
|
45 | - */ |
|
46 | - public function getProperties() |
|
47 | - { |
|
48 | - $properties = get_object_vars($this); |
|
49 | - unset($properties['di']); |
|
50 | - unset($properties['db']); |
|
41 | + /** |
|
42 | + * Get object properties. |
|
43 | + * |
|
44 | + * @return array with object properties. |
|
45 | + */ |
|
46 | + public function getProperties() |
|
47 | + { |
|
48 | + $properties = get_object_vars($this); |
|
49 | + unset($properties['di']); |
|
50 | + unset($properties['db']); |
|
51 | 51 | |
52 | - return $properties; |
|
53 | - } |
|
52 | + return $properties; |
|
53 | + } |
|
54 | 54 | |
55 | 55 | |
56 | - /** |
|
57 | - * Find and return specific. |
|
58 | - * |
|
59 | - * @return this |
|
60 | - */ |
|
61 | - public function find($id) |
|
62 | - { |
|
56 | + /** |
|
57 | + * Find and return specific. |
|
58 | + * |
|
59 | + * @return this |
|
60 | + */ |
|
61 | + public function find($id) |
|
62 | + { |
|
63 | 63 | $this->db->select() |
64 | - ->from($this->getSource()) |
|
65 | - ->where("id = ?"); |
|
64 | + ->from($this->getSource()) |
|
65 | + ->where("id = ?"); |
|
66 | 66 | |
67 | 67 | $this->db->execute([$id]); |
68 | 68 | return $this->db->fetchInto($this); |
69 | - } |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * Save current object/row. |
|
73 | - * |
|
74 | - * @param array $values key/values to save or empty to use object properties. |
|
75 | - * |
|
76 | - * @return boolean true or false if saving went okey. |
|
77 | - */ |
|
71 | + /** |
|
72 | + * Save current object/row. |
|
73 | + * |
|
74 | + * @param array $values key/values to save or empty to use object properties. |
|
75 | + * |
|
76 | + * @return boolean true or false if saving went okey. |
|
77 | + */ |
|
78 | 78 | public function save($values = []) |
79 | 79 | { |
80 | 80 | |
@@ -86,151 +86,151 @@ discard block |
||
86 | 86 | } else { |
87 | 87 | return $this->create($values); |
88 | 88 | } |
89 | - } |
|
89 | + } |
|
90 | 90 | |
91 | - /** |
|
92 | - * Set object properties. |
|
93 | - * |
|
94 | - * @param array $properties with properties to set. |
|
95 | - * |
|
96 | - * @return void |
|
97 | - */ |
|
98 | - public function setProperties($properties) |
|
99 | - { |
|
100 | - // Update object with incoming values, if any |
|
101 | - if (!empty($properties)) { |
|
102 | - foreach ($properties as $key => $val) { |
|
103 | - $this->$key = $val; |
|
104 | - } |
|
105 | - } |
|
106 | - } |
|
91 | + /** |
|
92 | + * Set object properties. |
|
93 | + * |
|
94 | + * @param array $properties with properties to set. |
|
95 | + * |
|
96 | + * @return void |
|
97 | + */ |
|
98 | + public function setProperties($properties) |
|
99 | + { |
|
100 | + // Update object with incoming values, if any |
|
101 | + if (!empty($properties)) { |
|
102 | + foreach ($properties as $key => $val) { |
|
103 | + $this->$key = $val; |
|
104 | + } |
|
105 | + } |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * Create new row. |
|
110 | - * |
|
111 | - * @param array $values key/values to save. |
|
112 | - * |
|
113 | - * @return boolean true or false if saving went okey. |
|
114 | - */ |
|
115 | - public function create($values) |
|
116 | - { |
|
117 | - $keys = array_keys($values); |
|
118 | - $values = array_values($values); |
|
108 | + /** |
|
109 | + * Create new row. |
|
110 | + * |
|
111 | + * @param array $values key/values to save. |
|
112 | + * |
|
113 | + * @return boolean true or false if saving went okey. |
|
114 | + */ |
|
115 | + public function create($values) |
|
116 | + { |
|
117 | + $keys = array_keys($values); |
|
118 | + $values = array_values($values); |
|
119 | 119 | |
120 | - $this->db->insert( |
|
121 | - $this->getSource(), |
|
122 | - $keys |
|
123 | - ); |
|
120 | + $this->db->insert( |
|
121 | + $this->getSource(), |
|
122 | + $keys |
|
123 | + ); |
|
124 | 124 | |
125 | - $res = $this->db->execute($values); |
|
125 | + $res = $this->db->execute($values); |
|
126 | 126 | |
127 | - $this->id = $this->db->lastInsertId(); |
|
127 | + $this->id = $this->db->lastInsertId(); |
|
128 | 128 | |
129 | - return $res; |
|
130 | - } |
|
129 | + return $res; |
|
130 | + } |
|
131 | 131 | |
132 | 132 | |
133 | - /** |
|
134 | - * Update row. |
|
135 | - * |
|
136 | - * @param array $values key/values to save. |
|
137 | - * |
|
138 | - * @return boolean true or false if saving went okey. |
|
139 | - */ |
|
140 | - public function update($values) |
|
141 | - { |
|
133 | + /** |
|
134 | + * Update row. |
|
135 | + * |
|
136 | + * @param array $values key/values to save. |
|
137 | + * |
|
138 | + * @return boolean true or false if saving went okey. |
|
139 | + */ |
|
140 | + public function update($values) |
|
141 | + { |
|
142 | 142 | |
143 | - $keys = array_keys($values); |
|
144 | - $values = array_values($values); |
|
143 | + $keys = array_keys($values); |
|
144 | + $values = array_values($values); |
|
145 | 145 | |
146 | - // Its update, remove id and use as where-clause |
|
147 | - unset($keys['id']); |
|
146 | + // Its update, remove id and use as where-clause |
|
147 | + unset($keys['id']); |
|
148 | 148 | |
149 | - $values[] = $this->id; |
|
149 | + $values[] = $this->id; |
|
150 | 150 | |
151 | - $this->db->update( |
|
152 | - $this->getSource(), |
|
153 | - $keys, |
|
154 | - "id = ?" |
|
155 | - ); |
|
151 | + $this->db->update( |
|
152 | + $this->getSource(), |
|
153 | + $keys, |
|
154 | + "id = ?" |
|
155 | + ); |
|
156 | 156 | |
157 | - return $this->db->execute($values); |
|
158 | - } |
|
157 | + return $this->db->execute($values); |
|
158 | + } |
|
159 | 159 | |
160 | - /** |
|
161 | - * Delete row. |
|
162 | - * |
|
163 | - * @param integer $id to delete. |
|
164 | - * |
|
165 | - * @return boolean true or false if deleting went okey. |
|
166 | - */ |
|
167 | - public function delete($id) |
|
168 | - { |
|
169 | - $this->db->delete( |
|
170 | - $this->getSource(), |
|
171 | - 'id = ?' |
|
172 | - ); |
|
160 | + /** |
|
161 | + * Delete row. |
|
162 | + * |
|
163 | + * @param integer $id to delete. |
|
164 | + * |
|
165 | + * @return boolean true or false if deleting went okey. |
|
166 | + */ |
|
167 | + public function delete($id) |
|
168 | + { |
|
169 | + $this->db->delete( |
|
170 | + $this->getSource(), |
|
171 | + 'id = ?' |
|
172 | + ); |
|
173 | 173 | |
174 | - return $this->db->execute([$id]); |
|
175 | - } |
|
174 | + return $this->db->execute([$id]); |
|
175 | + } |
|
176 | 176 | |
177 | 177 | |
178 | - /** |
|
179 | - * Build a select-query. |
|
180 | - * |
|
181 | - * @param string $columns which columns to select. |
|
182 | - * |
|
183 | - * @return $this |
|
184 | - */ |
|
185 | - public function query($columns = '*') |
|
186 | - { |
|
187 | - $this->db->select($columns) |
|
188 | - ->from($this->getSource()); |
|
178 | + /** |
|
179 | + * Build a select-query. |
|
180 | + * |
|
181 | + * @param string $columns which columns to select. |
|
182 | + * |
|
183 | + * @return $this |
|
184 | + */ |
|
185 | + public function query($columns = '*') |
|
186 | + { |
|
187 | + $this->db->select($columns) |
|
188 | + ->from($this->getSource()); |
|
189 | 189 | |
190 | - return $this; |
|
191 | - } |
|
190 | + return $this; |
|
191 | + } |
|
192 | 192 | |
193 | - /** |
|
194 | - * Build the where part. |
|
195 | - * |
|
196 | - * @param string $condition for building the where part of the query. |
|
197 | - * |
|
198 | - * @return $this |
|
199 | - */ |
|
200 | - public function where($condition) |
|
201 | - { |
|
202 | - $this->db->where($condition); |
|
193 | + /** |
|
194 | + * Build the where part. |
|
195 | + * |
|
196 | + * @param string $condition for building the where part of the query. |
|
197 | + * |
|
198 | + * @return $this |
|
199 | + */ |
|
200 | + public function where($condition) |
|
201 | + { |
|
202 | + $this->db->where($condition); |
|
203 | 203 | |
204 | - return $this; |
|
205 | - } |
|
204 | + return $this; |
|
205 | + } |
|
206 | 206 | |
207 | - /** |
|
208 | - * Build the where part. |
|
209 | - * |
|
210 | - * @param string $condition for building the where part of the query. |
|
211 | - * |
|
212 | - * @return $this |
|
213 | - */ |
|
214 | - public function andWhere($condition) |
|
215 | - { |
|
216 | - $this->db->andWhere($condition); |
|
207 | + /** |
|
208 | + * Build the where part. |
|
209 | + * |
|
210 | + * @param string $condition for building the where part of the query. |
|
211 | + * |
|
212 | + * @return $this |
|
213 | + */ |
|
214 | + public function andWhere($condition) |
|
215 | + { |
|
216 | + $this->db->andWhere($condition); |
|
217 | 217 | |
218 | - return $this; |
|
219 | - } |
|
218 | + return $this; |
|
219 | + } |
|
220 | 220 | |
221 | - /** |
|
222 | - * Execute the query built. |
|
223 | - * |
|
224 | - * @param array $params |
|
225 | - * |
|
226 | - * @return $this |
|
227 | - */ |
|
228 | - public function execute($params = []) |
|
229 | - { |
|
230 | - $this->db->execute($this->db->getSQL(), $params); |
|
231 | - $this->db->setFetchModeClass(__CLASS__); |
|
221 | + /** |
|
222 | + * Execute the query built. |
|
223 | + * |
|
224 | + * @param array $params |
|
225 | + * |
|
226 | + * @return $this |
|
227 | + */ |
|
228 | + public function execute($params = []) |
|
229 | + { |
|
230 | + $this->db->execute($this->db->getSQL(), $params); |
|
231 | + $this->db->setFetchModeClass(__CLASS__); |
|
232 | 232 | |
233 | - return $this->db->fetchAll(); |
|
234 | - } |
|
233 | + return $this->db->fetchAll(); |
|
234 | + } |
|
235 | 235 | |
236 | 236 | } |