@@ -5,12 +5,12 @@ |
||
5 | 5 | use HnrAzevedo\Datamanager\Model; |
6 | 6 | |
7 | 7 | /** |
8 | - * @property string $name |
|
9 | - * @property string $email |
|
10 | - * @property string $password |
|
11 | - * @property string birth |
|
12 | - * @property string register |
|
13 | - */ |
|
8 | + * @property string $name |
|
9 | + * @property string $email |
|
10 | + * @property string $password |
|
11 | + * @property string birth |
|
12 | + * @property string register |
|
13 | + */ |
|
14 | 14 | class User extends Model{ |
15 | 15 | |
16 | 16 | public function __construct() |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * @property string birth |
12 | 12 | * @property string register |
13 | 13 | */ |
14 | -class User extends Model{ |
|
14 | +class User extends Model { |
|
15 | 15 | |
16 | 16 | public function __construct() |
17 | 17 | { |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | * @param string Table name |
20 | 20 | * @param string Primary key column |
21 | 21 | */ |
22 | - parent::create('user','id'); |
|
22 | + parent::create('user', 'id'); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | } |
26 | 26 | \ No newline at end of file |
@@ -9,21 +9,21 @@ discard block |
||
9 | 9 | use HnrAzevedo\Datamanager\DatamanagerException; |
10 | 10 | use Model\User; |
11 | 11 | |
12 | -try{ |
|
12 | +try { |
|
13 | 13 | $entity = new User(); |
14 | 14 | |
15 | 15 | /* Find by primary key */ |
16 | 16 | $user = $entity->find(1)->execute()->first()->toEntity(); |
17 | 17 | |
18 | 18 | /* Search only for columns defined in advance */ |
19 | - $user = $entity->find(1)->only(['name','email'])->execute()->first(); |
|
19 | + $user = $entity->find(1)->only(['name', 'email'])->execute()->first(); |
|
20 | 20 | $name = $user->name; |
21 | 21 | $email = $user->email; |
22 | 22 | /* OR */ |
23 | 23 | $name = $entity->find()->only('name')->execute()->first()->name; |
24 | 24 | |
25 | 25 | /* Search except for columns defined in advance */ |
26 | - $user = $entity->find()->except(['name','email'])->execute()->first(); |
|
26 | + $user = $entity->find()->except(['name', 'email'])->execute()->first(); |
|
27 | 27 | /* OR */ |
28 | 28 | $user = $entity->find()->except('name')->execute()->first(); |
29 | 29 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | /* OrdeBy example */ |
36 | 36 | $users = $entity->find()->orderBy('birth ASC')->execute()->result(); |
37 | 37 | /* OR */ |
38 | - $users = $entity->find()->orderBy('birth','ASC')->execute()->result(); |
|
38 | + $users = $entity->find()->orderBy('birth', 'ASC')->execute()->result(); |
|
39 | 39 | |
40 | 40 | |
41 | 41 | /* Between example */ |
@@ -65,9 +65,9 @@ discard block |
||
65 | 65 | |
66 | 66 | /* Where example */ |
67 | 67 | $user->find()->where([ |
68 | - ['name','=','Henri Azevedo'], |
|
68 | + ['name', '=', 'Henri Azevedo'], |
|
69 | 69 | 'OR' => [ |
70 | - 'email','LIKE','[email protected]' |
|
70 | + 'email', 'LIKE', '[email protected]' |
|
71 | 71 | ] |
72 | 72 | ])->execute(); |
73 | 73 | |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | /* Searches for all records and returns an array of Model\User objects */ |
78 | 78 | $results = $entity->find()->execute()->toEntity(); |
79 | 79 | |
80 | -}catch(DatamanagerException $er){ |
|
80 | +} catch (DatamanagerException $er) { |
|
81 | 81 | |
82 | 82 | die("Code Error: {$er->getCode()}, Line: {$er->getLine()}, File: {$er->getFile()}, Message: {$er->getMessage()}."); |
83 | 83 |
@@ -15,24 +15,24 @@ |
||
15 | 15 | if (empty(self::$instance)) { |
16 | 16 | try { |
17 | 17 | |
18 | - if(!defined('DATAMANAGER_CONFIG')){ |
|
18 | + if (!defined('DATAMANAGER_CONFIG')) { |
|
19 | 19 | throw new DatamanagerException("Information for connection to the database not defined."); |
20 | 20 | } |
21 | 21 | |
22 | 22 | self::$instance = new PDO( |
23 | - DATAMANAGER_CONFIG['driver'] . ':host='.DATAMANAGER_CONFIG['host'] . ';port='.DATAMANAGER_CONFIG['port'] . ';dbname='.DATAMANAGER_CONFIG['database'] . ';charset='.DATAMANAGER_CONFIG['charset'], |
|
23 | + DATAMANAGER_CONFIG['driver'].':host='.DATAMANAGER_CONFIG['host'].';port='.DATAMANAGER_CONFIG['port'].';dbname='.DATAMANAGER_CONFIG['database'].';charset='.DATAMANAGER_CONFIG['charset'], |
|
24 | 24 | DATAMANAGER_CONFIG['username'], |
25 | 25 | DATAMANAGER_CONFIG['password'], |
26 | 26 | DATAMANAGER_CONFIG['options'] |
27 | 27 | ); |
28 | 28 | } catch (Exception $exception) { |
29 | - throw new DatamanagerException(str_replace(['SQLSTATE[HY000]',"[{$exception->getCode()}]"], '', $exception->getMessage()), $exception->getCode(), $exception); |
|
29 | + throw new DatamanagerException(str_replace(['SQLSTATE[HY000]', "[{$exception->getCode()}]"], '', $exception->getMessage()), $exception->getCode(), $exception); |
|
30 | 30 | } |
31 | 31 | } |
32 | 32 | return self::$instance; |
33 | 33 | } |
34 | 34 | |
35 | - public static function destroy(){ |
|
35 | + public static function destroy() { |
|
36 | 36 | self::$instance = null; |
37 | 37 | } |
38 | 38 |