3
3
* SQL database management to be used by several providers at the same time.
4
4
*
5
5
* @author Josantonius <[email protected] >
6
- * @copyright 2017 (c) Josantonius - PHP-Database
6
+ * @copyright 2017 - 2018 (c) Josantonius - PHP-Database
7
7
* @license https://opensource.org/licenses/MIT - The MIT License (MIT)
8
8
* @link https://github.com/Josantonius/PHP-Database
9
9
* @since 1.0.0
14
14
15
15
/**
16
16
* Database handler.
17
- *
18
- * @since 1.0.0
19
17
*/
20
18
class Database
21
19
{
@@ -31,35 +29,27 @@ class Database
31
29
/**
32
30
* Database provider.
33
31
*
34
- * @since 1.0.0
35
- *
36
32
* @var object
37
33
*/
38
34
public $ provider ;
39
35
40
36
/**
41
37
* Last insert id of the last query.
42
38
*
43
- * @since 1.0.0
44
- *
45
39
* @var int
46
40
*/
47
41
public $ lastInsertId ;
48
42
49
43
/**
50
44
* Get number of rows affected of the last query.
51
45
*
52
- * @since 1.0.0
53
- *
54
46
* @var int
55
47
*/
56
48
public $ rowCount ;
57
49
58
50
/**
59
51
* Configurations for queries.
60
52
*
61
- * @since 1.0.0
62
- *
63
53
* @var null|array
64
54
*/
65
55
protected $ settings = [
@@ -83,35 +73,27 @@ class Database
83
73
/**
84
74
* Database connection.
85
75
*
86
- * @since 1.0.0
87
- *
88
76
* @var array
89
77
*/
90
78
private static $ conn ;
91
79
92
80
/**
93
81
* Query.
94
82
*
95
- * @since 1.0.0
96
- *
97
83
* @var string
98
84
*/
99
85
private $ query ;
100
86
101
87
/**
102
88
* Query response.
103
89
*
104
- * @since 1.0.0
105
- *
106
90
* @var object
107
91
*/
108
92
private $ response ;
109
93
110
94
/**
111
95
* Database provider constructor.
112
96
*
113
- * @since 1.0.0
114
- *
115
97
* @param string $provider → name of provider class
116
98
* @param string $host → database host
117
99
* @param string $user → database user
@@ -152,8 +134,6 @@ protected function __construct(
152
134
153
135
/**
154
136
* Close connection to database.
155
- *
156
- * @since 1.0.0
157
137
*/
158
138
public function __destruct ()
159
139
{
@@ -165,8 +145,6 @@ public function __destruct()
165
145
*
166
146
* Create a new if it doesn't exist or another provider is used.
167
147
*
168
- * @since 1.0.0
169
- *
170
148
* @param string $id → identifying name for the database
171
149
* @param string $provider → name of provider class
172
150
* @param string $host → database host
@@ -214,8 +192,6 @@ public static function getConnection(
214
192
/**
215
193
* Process query and prepare it for the provider.
216
194
*
217
- * @since 1.0.0
218
- *
219
195
* @param string $query → query
220
196
* @param array $statements → null by default or array for statements
221
197
*
@@ -254,8 +230,6 @@ public function query($query, $statements = null, $result = 'obj')
254
230
/**
255
231
* Create table statement.
256
232
*
257
- * @since 1.0.0
258
- *
259
233
* @param array $data → column name and configuration for data types
260
234
*
261
235
* @return object
@@ -365,8 +339,6 @@ public function charset($type)
365
339
/**
366
340
* Select statement.
367
341
*
368
- * @since 1.0.0
369
- *
370
342
* @param mixed $columns → column/s name
371
343
*
372
344
* @return object
@@ -382,8 +354,6 @@ public function select($columns = '*')
382
354
/**
383
355
* Insert into statement.
384
356
*
385
- * @since 1.0.0
386
- *
387
357
* @param array $data → column name and value
388
358
* @param array $statements → null by default or array for statements
389
359
*
@@ -401,8 +371,6 @@ public function insert($data, $statements = null)
401
371
/**
402
372
* Update statement.
403
373
*
404
- * @since 1.0.0
405
- *
406
374
* @param array $data → column name and value
407
375
* @param array $statements → null by default or array for statements
408
376
*
@@ -420,8 +388,6 @@ public function update($data, $statements = null)
420
388
/**
421
389
* Replace a row in a table if it exists or insert a new row if not exist.
422
390
*
423
- * @since 1.0.0
424
- *
425
391
* @param array $data → column name and value
426
392
* @param array $statements → null by default or array for statements
427
393
*
@@ -439,8 +405,6 @@ public function replace($data, $statements = null)
439
405
/**
440
406
* Delete statement.
441
407
*
442
- * @since 1.0.0
443
- *
444
408
* @return object
445
409
*/
446
410
public function delete ()
@@ -453,8 +417,6 @@ public function delete()
453
417
/**
454
418
* Truncate table statement.
455
419
*
456
- * @since 1.0.0
457
- *
458
420
* @return object
459
421
*/
460
422
public function truncate ()
@@ -467,8 +429,6 @@ public function truncate()
467
429
/**
468
430
* Drop table statement.
469
431
*
470
- * @since 1.0.0
471
- *
472
432
* @return object
473
433
*/
474
434
public function drop ()
@@ -481,8 +441,6 @@ public function drop()
481
441
/**
482
442
* Set database table name.
483
443
*
484
- * @since 1.0.0
485
- *
486
444
* @param string $table → table name
487
445
*
488
446
* @return object
@@ -497,8 +455,6 @@ public function in($table)
497
455
/**
498
456
* Set database table name.
499
457
*
500
- * @since 1.0.0
501
- *
502
458
* @param string $table → table name
503
459
*
504
460
* @return object
@@ -513,8 +469,6 @@ public function table($table)
513
469
/**
514
470
* Set database table name.
515
471
*
516
- * @since 1.0.0
517
- *
518
472
* @param string $table → table name
519
473
*
520
474
* @return object
@@ -529,8 +483,6 @@ public function from($table)
529
483
/**
530
484
* Where clauses.
531
485
*
532
- * @since 1.0.0
533
- *
534
486
* @param mixed $clauses → column name and value
535
487
* @param array $statements → null by default or array for statements
536
488
*
@@ -555,8 +507,6 @@ public function where($clauses, $statements = null)
555
507
/**
556
508
* Set SELECT order.
557
509
*
558
- * @since 1.0.0
559
- *
560
510
* @param string $type → query sort parameters
561
511
*
562
512
* @return object
@@ -571,8 +521,6 @@ public function order($type)
571
521
/**
572
522
* Set SELECT limit.
573
523
*
574
- * @since 1.0.0
575
- *
576
524
* @param int $number → query limiting parameters
577
525
*
578
526
* @return object
@@ -587,8 +535,6 @@ public function limit($number)
587
535
/**
588
536
* Execute query.
589
537
*
590
- * @since 1.0.0
591
- *
592
538
* @param string $result → 'obj' → result as object
593
539
* → 'array_num' → result as numeric array
594
540
* → 'array_assoc' → result as associative array
@@ -680,8 +626,6 @@ public function execute($result = 'obj')
680
626
/**
681
627
* Query handler.
682
628
*
683
- * @since 1.0.0
684
- *
685
629
* @return object → returns query to be executed by provider class
686
630
*/
687
631
private function implement ()
@@ -695,8 +639,6 @@ private function implement()
695
639
696
640
/**
697
641
* Run query with prepared statements.
698
- *
699
- * @since 1.0.0
700
642
*/
701
643
private function implementPrepareStatements ()
702
644
{
@@ -708,8 +650,6 @@ private function implementPrepareStatements()
708
650
709
651
/**
710
652
* Run query without prepared statements.
711
- *
712
- * @since 1.0.0
713
653
*/
714
654
private function implementQuery ()
715
655
{
@@ -722,8 +662,6 @@ private function implementQuery()
722
662
/**
723
663
* Get response after executing the query.
724
664
*
725
- * @since 1.0.0
726
- *
727
665
* @throws DBException → error executing query
728
666
*
729
667
* @return mixed → result as object, array, int...
@@ -746,8 +684,6 @@ private function getResponse()
746
684
/**
747
685
* Process query as object or numeric or associative array.
748
686
*
749
- * @since 1.0.0
750
- *
751
687
* @return mixed|bool → results
752
688
*/
753
689
private function fetchResponse ()
@@ -777,8 +713,6 @@ private function fetchResponse()
777
713
778
714
/**
779
715
* Reset query parameters.
780
- *
781
- * @since 1.0.0
782
716
*/
783
717
private function reset ()
784
718
{
0 commit comments