@@ -7,42 +7,42 @@ |
||
| 7 | 7 | $this->connection = []; |
| 8 | 8 | $this->currentConnection = null; |
| 9 | 9 | } |
| 10 | - public function addConnection( $_name, $_connection ) { |
|
| 10 | + public function addConnection($_name, $_connection) { |
|
| 11 | 11 | $this->connection["$_name"] = $_connection; |
| 12 | 12 | $this->currentConnection = $_connection; |
| 13 | 13 | |
| 14 | 14 | foreach ($this->modules as &$module) |
| 15 | - if(isset($module->currentConnection)) |
|
| 15 | + if (isset($module->currentConnection)) |
|
| 16 | 16 | $module->addConnection($_name, $_connection); |
| 17 | 17 | } |
| 18 | - public function setConnection( $_name ) { |
|
| 18 | + public function setConnection($_name) { |
|
| 19 | 19 | $this->currentConnection = $this->connection["$_name"]; |
| 20 | 20 | } |
| 21 | - public function query( $_query ) { |
|
| 21 | + public function query($_query) { |
|
| 22 | 22 | $this->stdQuery($_query); |
| 23 | 23 | return true; |
| 24 | 24 | } |
| 25 | - public function queryInsert( $_query ) { |
|
| 25 | + public function queryInsert($_query) { |
|
| 26 | 26 | $temp = $this->stdQuery($_query); |
| 27 | 27 | return $this->currentConnection->database->lastInsertId(); |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - public function queryFetch( $_query ) { |
|
| 30 | + public function queryFetch($_query) { |
|
| 31 | 31 | $temp = $this->stdQuery($_query); |
| 32 | 32 | return $temp->fetchAll(PDO::FETCH_ASSOC); |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - public function queryArray( $_query ) { |
|
| 35 | + public function queryArray($_query) { |
|
| 36 | 36 | $temp = $this->stdQuery($_query); |
| 37 | 37 | return $temp->fetchAll(PDO::FETCH_COLUMN, 0); |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - protected function stdQuery( $_query ) { |
|
| 40 | + protected function stdQuery($_query) { |
|
| 41 | 41 | $database = $this->currentConnection->database; |
| 42 | 42 | $error = "Error query [$_query]"; |
| 43 | 43 | $query = $database->prepare($_query); |
| 44 | 44 | $_result = $query->execute(); |
| 45 | - if(!$_result) { |
|
| 45 | + if (!$_result) { |
|
| 46 | 46 | echo "$_query<br>"; |
| 47 | 47 | echo "Something wrong: $error"; |
| 48 | 48 | var_dump($query->errorInfo()); |
@@ -11,9 +11,10 @@ |
||
| 11 | 11 | $this->connection["$_name"] = $_connection; |
| 12 | 12 | $this->currentConnection = $_connection; |
| 13 | 13 | |
| 14 | - foreach ($this->modules as &$module) |
|
| 15 | - if(isset($module->currentConnection)) |
|
| 14 | + foreach ($this->modules as &$module) { |
|
| 15 | + if(isset($module->currentConnection)) |
|
| 16 | 16 | $module->addConnection($_name, $_connection); |
| 17 | + } |
|
| 17 | 18 | } |
| 18 | 19 | public function setConnection( $_name ) { |
| 19 | 20 | $this->currentConnection = $this->connection["$_name"]; |