Skip to content

Commit 522ba5e

Browse files
committed
Update Project at Mon Mar 27 14:29:16 +07 2023
1 parent bcc5dce commit 522ba5e

File tree

3 files changed

+35
-6
lines changed

3 files changed

+35
-6
lines changed

config/constants.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@
1818
defined('POWERED_HUNGNG_SHORT_NAME') or define('POWERED_HUNGNG_SHORT_NAME', 'Hung Nguyen');
1919
defined('CODEIGNITER_HUNGNG_VENDOR_PACKAGES') or define('CODEIGNITER_HUNGNG_VENDOR_PACKAGES', 'https://packagist.org/packages/nguyenanhung/codeigniter-framework');
2020
defined('CODEIGNITER_HUNGNG_VENDOR_SOURCE') or define('CODEIGNITER_HUNGNG_VENDOR_SOURCE', 'https://github.com/nguyenanhung/codeigniter-framework');
21+
defined('CI3_FRAMEWORK_ISSUES') or define('CI3_FRAMEWORK_ISSUES', 'https://github.com/nguyenanhung/codeigniter-framework/issues');
22+
defined('CI3_FRAMEWORK_PULL_REQUESTS') or define('CI3_FRAMEWORK_PULL_REQUESTS', 'https://github.com/nguyenanhung/codeigniter-framework/pulls');

hungng/HungNG_CI_Exception.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
defined('BASEPATH') or exit('No direct script access allowed');
3+
4+
class HungNG_CI_Exception extends Exception
5+
{
6+
/**
7+
* HungNG_CI_Exception constructor.
8+
*
9+
* @param $message
10+
* @param $code
11+
*
12+
* @throws \HungNG_CI_Exception
13+
*
14+
* @author : 713uk13m <dev@nguyenanhung.com>
15+
* @copyright: 713uk13m <dev@nguyenanhung.com>
16+
*/
17+
public function __construct($message = null, $code = 0)
18+
{
19+
if (!$message) {
20+
throw new $this('Unknown ' . get_class($this));
21+
}
22+
$error_message = $message . ' - If you believe this is a codebase or framework bug, please report it and let us know here: ' . CI3_FRAMEWORK_ISSUES . ' - Codebase will be improved by your contributions. Thank you!';
23+
parent::__construct($error_message, $code);
24+
}
25+
}

hungng/HungNG_Custom_Based_model.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -529,9 +529,10 @@ public function prepare_wheres_not_statement($wheres)
529529
* @param $table
530530
*
531531
* @return bool|\CI_DB_query_builder|object
532+
* @throws \HungNG_CI_Exception
532533
* @author : 713uk13m <dev@nguyenanhung.com>
533534
* @copyright: 713uk13m <dev@nguyenanhung.com>
534-
* @time : 08/02/2023 42:52
535+
* @time : 27/03/2023 15:20
535536
*/
536537
public function only_status_is_active($act = true, $field = 'status', $table = '')
537538
{
@@ -540,11 +541,11 @@ public function only_status_is_active($act = true, $field = 'status', $table = '
540541
$useField = !empty($field) ? trim($field) : 'status';
541542
$tableExists = $this->db->table_exists($tableName);
542543
if ($tableExists === false) {
543-
return $this->db;
544+
throw new HungNG_CI_Exception('Table ' . $tableName . ' không tồn tại', 404);
544545
}
545546
$fieldExists = $this->db->field_exists($useField, $tableName);
546547
if ($fieldExists === false) {
547-
return $this->db;
548+
throw new HungNG_CI_Exception('Field ' . $useField . ' không tìm thấy trong bảng ' . $tableName, 404);
548549
}
549550

550551
return $this->db->where($tableName . '.' . $useField, self::DEFAULT_STATUS_IS_ACTIVE);
@@ -561,9 +562,10 @@ public function only_status_is_active($act = true, $field = 'status', $table = '
561562
* @param $table
562563
*
563564
* @return bool|\CI_DB_query_builder|object
565+
* @throws \HungNG_CI_Exception
564566
* @author : 713uk13m <dev@nguyenanhung.com>
565567
* @copyright: 713uk13m <dev@nguyenanhung.com>
566-
* @time : 08/02/2023 42:52
568+
* @time : 27/03/2023 17:52
567569
*/
568570
public function only_status_is_de_active($act = true, $field = 'status', $table = '')
569571
{
@@ -572,11 +574,11 @@ public function only_status_is_de_active($act = true, $field = 'status', $table
572574
$useField = !empty($field) ? trim($field) : 'status';
573575
$tableExists = $this->db->table_exists($tableName);
574576
if ($tableExists === false) {
575-
return $this->db;
577+
throw new HungNG_CI_Exception('Table ' . $tableName . ' không tồn tại', 404);
576578
}
577579
$fieldExists = $this->db->field_exists($useField, $tableName);
578580
if ($fieldExists === false) {
579-
return $this->db;
581+
throw new HungNG_CI_Exception('Field ' . $useField . ' không tìm thấy trong bảng ' . $tableName, 404);
580582
}
581583

582584
return $this->db->where($tableName . '.' . $useField, self::DEFAULT_STATUS_IS_DE_ACTIVE);

0 commit comments

Comments
 (0)