@@ -37,12 +37,12 @@ |
||
| 37 | 37 | |
| 38 | 38 | |
| 39 | 39 | /** |
| 40 | - * Add the configurations using the method addConfig, accepts various configurations |
|
| 41 | - * Arguments: |
|
| 42 | - * - $connection->addConfig('driver', 'user', 'password', 'host', 'database', 'connectionName', 'port'); |
|
| 43 | - * - Driver options ['mysql', 'pgsql'] -- Mysql, postgres |
|
| 44 | - * @return Connection |
|
| 45 | - */ |
|
| 40 | + * Add the configurations using the method addConfig, accepts various configurations |
|
| 41 | + * Arguments: |
|
| 42 | + * - $connection->addConfig('driver', 'user', 'password', 'host', 'database', 'connectionName', 'port'); |
|
| 43 | + * - Driver options ['mysql', 'pgsql'] -- Mysql, postgres |
|
| 44 | + * @return Connection |
|
| 45 | + */ |
|
| 46 | 46 | |
| 47 | 47 | $connectionManager = ConnectionManager::initialize(function ($connection) { |
| 48 | 48 | $connection->addConfig('mysql', 'root', '', 'localhost', 'local_controlook', 'local', 3306); |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | * @return Connection |
| 45 | 45 | */ |
| 46 | 46 | |
| 47 | - $connectionManager = ConnectionManager::initialize(function ($connection) { |
|
| 47 | + $connectionManager = ConnectionManager::initialize(function($connection) { |
|
| 48 | 48 | $connection->addConfig('mysql', 'root', '', 'localhost', 'local_controlook', 'local', 3306); |
| 49 | 49 | $connection->addConfig('pgsql', 'postgres', '123456', 'localhost', 'local_controlook', 'postgres_local', 5432); |
| 50 | 50 | |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | /** |
| 62 | 62 | * 4. Instantiate the model |
| 63 | 63 | */ |
| 64 | - $connectionManager = ConnectionManager::initialize(function ($connection) { |
|
| 64 | + $connectionManager = ConnectionManager::initialize(function($connection) { |
|
| 65 | 65 | $connection->addConfig('mysql', 'root', '', 'localhost', 'local_controlook', 'local', 3306); |
| 66 | 66 | $connection->addConfig('pgsql', 'postgres', '123456', 'localhost', 'local_controlook', 'postgres_local', 5432); |
| 67 | 67 | |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | * @param \Closure $connection |
| 37 | 37 | * @return \ConnectionManager |
| 38 | 38 | */ |
| 39 | - $connectionManager = ConnectionManager::initialize(function ($connection) { |
|
| 39 | + $connectionManager = ConnectionManager::initialize(function($connection) { |
|
| 40 | 40 | /** |
| 41 | 41 | * Add the configurations using the method addConfig, accepts various configurations |
| 42 | 42 | * Arguments: |
@@ -63,9 +63,9 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | $usage->delete(); |
| 65 | 65 | |
| 66 | - if($usage){ |
|
| 66 | + if ($usage) { |
|
| 67 | 67 | |
| 68 | - }else{ |
|
| 68 | + }else { |
|
| 69 | 69 | echo 'Haven\'t data for this ID.'; |
| 70 | 70 | } |
| 71 | 71 | |
@@ -65,7 +65,7 @@ |
||
| 65 | 65 | |
| 66 | 66 | if($usage){ |
| 67 | 67 | |
| 68 | - }else{ |
|
| 68 | + } else{ |
|
| 69 | 69 | echo 'Haven\'t data for this ID.'; |
| 70 | 70 | } |
| 71 | 71 | |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * @param \Closure $connection |
| 38 | 38 | * @return \ConnectionManager |
| 39 | 39 | */ |
| 40 | - $connectionManager = ConnectionManager::initialize(function ($connection) { |
|
| 40 | + $connectionManager = ConnectionManager::initialize(function($connection) { |
|
| 41 | 41 | /** |
| 42 | 42 | * Add the configurations using the method addConfig, accepts various configurations |
| 43 | 43 | * Arguments: |
@@ -70,9 +70,9 @@ discard block |
||
| 70 | 70 | var_dump($useQuery); |
| 71 | 71 | |
| 72 | 72 | |
| 73 | - if(count($usage) > 0){ |
|
| 73 | + if (count($usage) > 0) { |
|
| 74 | 74 | var_dump($usage); |
| 75 | - }else{ |
|
| 75 | + }else { |
|
| 76 | 76 | echo 'Haven\'t data for this Model.'; |
| 77 | 77 | } |
| 78 | 78 | |
@@ -72,7 +72,7 @@ |
||
| 72 | 72 | |
| 73 | 73 | if(count($usage) > 0){ |
| 74 | 74 | var_dump($usage); |
| 75 | - }else{ |
|
| 75 | + } else{ |
|
| 76 | 76 | echo 'Haven\'t data for this Model.'; |
| 77 | 77 | } |
| 78 | 78 | |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * @param \Closure $connection |
| 33 | 33 | * @return \ConnectionManager |
| 34 | 34 | */ |
| 35 | - $connectionManager = ConnectionManager::initialize(function ($connection) { |
|
| 35 | + $connectionManager = ConnectionManager::initialize(function($connection) { |
|
| 36 | 36 | /** |
| 37 | 37 | * Add the configurations using the method addConfig, accepts various configurations |
| 38 | 38 | * Arguments: |
@@ -54,10 +54,10 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | $usage = UsageModel::create(['id2' => '55', 'nome' => 'Teste create']); |
| 56 | 56 | |
| 57 | - if($usage){ |
|
| 58 | - echo 'Id: '.$usage->id.'<br />'; |
|
| 59 | - echo 'Nome: '.$usage->nome.'<br />'; |
|
| 60 | - }else{ |
|
| 57 | + if ($usage) { |
|
| 58 | + echo 'Id: ' . $usage->id . '<br />'; |
|
| 59 | + echo 'Nome: ' . $usage->nome . '<br />'; |
|
| 60 | + }else { |
|
| 61 | 61 | echo 'This data haven\'t save.'; |
| 62 | 62 | } |
| 63 | 63 | |
@@ -57,7 +57,7 @@ |
||
| 57 | 57 | if($usage){ |
| 58 | 58 | echo 'Id: '.$usage->id.'<br />'; |
| 59 | 59 | echo 'Nome: '.$usage->nome.'<br />'; |
| 60 | - }else{ |
|
| 60 | + } else{ |
|
| 61 | 61 | echo 'This data haven\'t save.'; |
| 62 | 62 | } |
| 63 | 63 | |
@@ -31,8 +31,8 @@ |
||
| 31 | 31 | * @return Array with object if exists the data |
| 32 | 32 | * @return Array haven't data |
| 33 | 33 | */ |
| 34 | - public function useQuery(){ |
|
| 35 | - return $this->query('SELECT * FROM '.static::$table_name); |
|
| 34 | + public function useQuery() { |
|
| 35 | + return $this->query('SELECT * FROM ' . static::$table_name); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | * @param \Closure $connection |
| 43 | 43 | * @return \ConnectionManager |
| 44 | 44 | */ |
| 45 | - $connectionManager = ConnectionManager::initialize(function ($connection) { |
|
| 45 | + $connectionManager = ConnectionManager::initialize(function($connection) { |
|
| 46 | 46 | /** |
| 47 | 47 | * Add the configurations using the method addConfig, accepts various configurations |
| 48 | 48 | * Arguments: |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | /** |
| 85 | 85 | * 5. Joins example |
| 86 | 86 | */ |
| 87 | - $result = UsageModel::select('chave_composta.id as chave_id, |
|
| 87 | + $result = UsageModel::select('chave_composta.id as chave_id, |
|
| 88 | 88 | chave_composta.id2 as chave_id2, |
| 89 | 89 | chave_composta.nome as chave_nome, |
| 90 | 90 | tb_usuarios.id as usuario_id, |
@@ -92,9 +92,9 @@ discard block |
||
| 92 | 92 | ->leftJoin('tb_usuarios ON tb_usuarios.id = chave_composta.id2') |
| 93 | 93 | ->orderBy('chave_composta.nome', 'DESC') |
| 94 | 94 | ->done(); |
| 95 | - if(count($usage) > 0){ |
|
| 95 | + if (count($usage) > 0) { |
|
| 96 | 96 | var_dump($usage); |
| 97 | - }else{ |
|
| 97 | + }else { |
|
| 98 | 98 | echo 'Haven\'t data for this Model.'; |
| 99 | 99 | } |
| 100 | 100 | |
@@ -94,7 +94,7 @@ |
||
| 94 | 94 | ->done(); |
| 95 | 95 | if(count($usage) > 0){ |
| 96 | 96 | var_dump($usage); |
| 97 | - }else{ |
|
| 97 | + } else{ |
|
| 98 | 98 | echo 'Haven\'t data for this Model.'; |
| 99 | 99 | } |
| 100 | 100 | |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | * @param \Closure $connection |
| 32 | 32 | * @return \ConnectionManager |
| 33 | 33 | */ |
| 34 | - $connectionManager = ConnectionManager::initialize(function ($connection) { |
|
| 34 | + $connectionManager = ConnectionManager::initialize(function($connection) { |
|
| 35 | 35 | /** |
| 36 | 36 | * 4. Add the configurations using the method addConfig, accepts various configurations |
| 37 | 37 | * Arguments: |
@@ -52,9 +52,9 @@ discard block |
||
| 52 | 52 | */ |
| 53 | 53 | $usage = UsageModel::all(); |
| 54 | 54 | |
| 55 | - if(count($usage) > 0){ |
|
| 55 | + if (count($usage) > 0) { |
|
| 56 | 56 | var_dump($usage); |
| 57 | - }else{ |
|
| 57 | + }else { |
|
| 58 | 58 | echo 'Haven\'t data for this Model.'; |
| 59 | 59 | } |
| 60 | 60 | |
@@ -72,7 +72,7 @@ |
||
| 72 | 72 | |
| 73 | 73 | if(count($usage) > 0){ |
| 74 | 74 | var_dump($usage); |
| 75 | - }else{ |
|
| 75 | + } else{ |
|
| 76 | 76 | echo 'Haven\'t data for this Model.'; |
| 77 | 77 | } |
| 78 | 78 | |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * @param \Closure $connection |
| 33 | 33 | * @return \ConnectionManager |
| 34 | 34 | */ |
| 35 | - $connectionManager = ConnectionManager::initialize(function ($connection) { |
|
| 35 | + $connectionManager = ConnectionManager::initialize(function($connection) { |
|
| 36 | 36 | /** |
| 37 | 37 | * Add the configurations using the method addConfig, accepts various configurations |
| 38 | 38 | * Arguments: |
@@ -54,10 +54,10 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | $usage = UsageModel::find(246); |
| 56 | 56 | |
| 57 | - if(!is_null($usage)){ |
|
| 58 | - echo 'Id: '.$usage->id.'<br />'; |
|
| 59 | - echo 'Nome: '.$usage->nome.'<br />'; |
|
| 60 | - }else{ |
|
| 57 | + if (!is_null($usage)) { |
|
| 58 | + echo 'Id: ' . $usage->id . '<br />'; |
|
| 59 | + echo 'Nome: ' . $usage->nome . '<br />'; |
|
| 60 | + }else { |
|
| 61 | 61 | echo 'Not have data for this ID.'; |
| 62 | 62 | } |
| 63 | 63 | |
@@ -57,7 +57,7 @@ |
||
| 57 | 57 | if(!is_null($usage)){ |
| 58 | 58 | echo 'Id: '.$usage->id.'<br />'; |
| 59 | 59 | echo 'Nome: '.$usage->nome.'<br />'; |
| 60 | - }else{ |
|
| 60 | + } else{ |
|
| 61 | 61 | echo 'Not have data for this ID.'; |
| 62 | 62 | } |
| 63 | 63 | |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | try { |
| 7 | 7 | |
| 8 | 8 | |
| 9 | - $connectionManager = ConnectionManager::inicialize(function ($connection) { |
|
| 9 | + $connectionManager = ConnectionManager::inicialize(function($connection) { |
|
| 10 | 10 | $connection->addConfig('mysql', 'root', '', 'localhost', 'local_controlook', 'local', 3306); |
| 11 | 11 | $connection->addConfig('mysql', 'root', '', 'localhost', 'local_controlook', 'teste', 3306); |
| 12 | 12 | |
@@ -18,6 +18,6 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | |
| 20 | 20 | |
| 21 | -}catch (Exception $e){ |
|
| 21 | +} catch (Exception $e) { |
|
| 22 | 22 | echo $e->getMessage(); |
| 23 | 23 | } |
| 24 | 24 | \ No newline at end of file |
@@ -18,6 +18,6 @@ |
||
| 18 | 18 | |
| 19 | 19 | |
| 20 | 20 | |
| 21 | -}catch (Exception $e){ |
|
| 21 | +} catch (Exception $e){ |
|
| 22 | 22 | echo $e->getMessage(); |
| 23 | 23 | } |
| 24 | 24 | \ No newline at end of file |