66 *
77 * @package PhpOrm
88 */
9- class DB
9+ class DB extends Base
1010{
1111 protected $ attributes = array ();
1212
@@ -53,7 +53,7 @@ class DB
5353 /**
5454 * DB constructor.
5555 *
56- * @throws \ Exception
56+ * @throws Exception
5757 */
5858 public function __construct () {
5959 $ this ->mount ();
@@ -64,7 +64,7 @@ public function __construct() {
6464 *
6565 * @param int $value
6666 * @return DB
67- * @throws \ Exception
67+ * @throws Exception
6868 */
6969 public function autoCommit (int $ value ): DB
7070 {
@@ -80,7 +80,7 @@ public function autoCommit(int $value): DB
8080 * Begin a new transaction
8181 *
8282 * @return DB
83- * @throws \ Exception
83+ * @throws Exception
8484 */
8585 public function begin (): DB
8686 {
@@ -225,7 +225,7 @@ protected function buildWhere(): string
225225 * Commits the current transaction, making its changes permanent
226226 *
227227 * @return DB
228- * @throws \ Exception
228+ * @throws Exception
229229 */
230230 public function commit (): DB
231231 {
@@ -246,7 +246,7 @@ public static function config(string $filename) {
246246
247247 /**
248248 * @return int|null
249- * @throws \ Exception
249+ * @throws Exception
250250 */
251251 public function count (): ?int
252252 {
@@ -297,7 +297,7 @@ public function debug(bool $value): DB
297297 /**
298298 * @param null $modifiers
299299 * @return int|null
300- * @throws \ Exception
300+ * @throws Exception
301301 */
302302 public function delete ($ modifiers = null ): ?int
303303 {
@@ -345,7 +345,7 @@ protected function dump()
345345 /**
346346 * @param $value
347347 * @return array|null
348- * @throws \ Exception
348+ * @throws Exception
349349 */
350350 public function find ($ value ): ?array
351351 {
@@ -362,25 +362,23 @@ public function find($value): ?array
362362 /**
363363 * @param string $statement
364364 * @return bool
365- * @throws \ Exception
365+ * @throws Exception
366366 */
367367 protected function fire (string $ statement ): bool
368368 {
369+ try {
369370 $ this ->sth = $ this ->dbh ->prepare ($ statement );
370- if (!$ this ->sth ) {
371- throw new \Exception ('Preparing statement failed. ' );
372- }
373-
374- if (!$ this ->sth ->execute ($ this ->params )) {
375- throw new \Exception ('Executing statement failed. ' );
371+ return $ this ->sth ->execute ($ this ->params );
372+ } catch (\PDOException $ e ) {
373+ $ this ->throwException ($ e ->getMessage ());
376374 }
377375
378376 return true ;
379377 }
380378
381379 /**
382380 * @return array|null
383- * @throws \ Exception
381+ * @throws Exception
384382 */
385383 public function first (): ?array
386384 {
@@ -393,7 +391,7 @@ public function first(): ?array
393391
394392 /**
395393 * @return array|null
396- * @throws \ Exception
394+ * @throws Exception
397395 */
398396 public function get (): ?array
399397 {
@@ -430,7 +428,7 @@ public function having(string $value = null): DB
430428 * @param array $data
431429 * @param null $modifiers
432430 * @return int|null
433- * @throws \ Exception
431+ * @throws Exception
434432 */
435433 public function insert (array $ data , $ modifiers = null ): ?int
436434 {
@@ -490,7 +488,7 @@ public function limit(int $rowCount = null, int $offset = null): DB
490488
491489 /**
492490 * @return DB
493- * @throws \ Exception
491+ * @throws Exception
494492 */
495493 protected function mount (): DB
496494 {
@@ -504,19 +502,19 @@ protected function mount(): DB
504502
505503 if (!is_file (self ::$ config ))
506504 {
507- throw new \ Exception ("File ' " .self ::$ config ."' not found. " );
505+ $ this -> throwException ("File ' " .self ::$ config ."' not found. " );
508506 }
509507 $ database = include self ::$ config ;
510508 if (!isset ($ database [$ this ->connection ]))
511509 {
512- throw new \ Exception ("Connection not found. " );
510+ $ this -> throwException ("Connection not found. " );
513511 }
514512 $ opts = $ database [$ this ->connection ];
515513 foreach (array ('username ' , 'password ' , 'database ' , 'host ' , 'port ' , 'driver ' , 'charset ' , 'collation ' ) as $ key )
516514 {
517515 if (!array_key_exists ($ key , $ opts ))
518516 {
519- throw new \ Exception ("The ' $ key' index was not found in config. " );
517+ $ this -> throwException ("The ' $ key' index was not found in config. " );
520518 }
521519 }
522520
@@ -574,7 +572,7 @@ public static function raw(string $value): Expression
574572 *
575573 * @param string $identifier
576574 * @return DB
577- * @throws \ Exception
575+ * @throws Exception
578576 */
579577 public function releaseSavepoint (string $ identifier ): DB
580578 {
@@ -590,7 +588,7 @@ public function releaseSavepoint(string $identifier): DB
590588 * @param array $data
591589 * @param null $modifiers
592590 * @return int|null
593- * @throws \ Exception
591+ * @throws Exception
594592 */
595593 public function replace (array $ data , $ modifiers = null ): ?int
596594 {
@@ -644,7 +642,7 @@ public function rightJoin(string $table, string $conditions): DB
644642 * Rolls back the current transaction, canceling its changes
645643 *
646644 * @return DB
647- * @throws \ Exception
645+ * @throws Exception
648646 */
649647 public function rollback (): DB
650648 {
@@ -661,7 +659,7 @@ public function rollback(): DB
661659 *
662660 * @param string $identifier
663661 * @return DB
664- * @throws \ Exception
662+ * @throws Exception
665663 */
666664 public function rollbackToSavepoint (string $ identifier ): DB
667665 {
@@ -678,7 +676,7 @@ public function rollbackToSavepoint(string $identifier): DB
678676 *
679677 * @param string $identifier
680678 * @return DB
681- * @throws \ Exception
679+ * @throws Exception
682680 */
683681 public function savepoint (string $ identifier ): DB
684682 {
@@ -730,7 +728,7 @@ public function truncate(): bool
730728 * @param array $data
731729 * @param null $modifiers
732730 * @return int
733- * @throws \ Exception
731+ * @throws Exception
734732 */
735733 public function update (array $ data , $ modifiers = null ): int
736734 {
@@ -788,7 +786,7 @@ public function update(array $data, $modifiers = null): int
788786 * @param array $data
789787 * @param null $modifiers
790788 * @return int|null
791- * @throws \ Exception
789+ * @throws Exception
792790 */
793791 public function upsert (array $ data , $ modifiers = null ): ?int
794792 {
@@ -802,7 +800,7 @@ public function upsert(array $data, $modifiers = null): ?int
802800 /**
803801 * @param string $column
804802 * @return string
805- * @throws \ Exception
803+ * @throws Exception
806804 */
807805 public function value (string $ column ): string
808806 {
0 commit comments