-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #84 from nguyenanhung/v3.x
Update Project at Tue Sep 26 12:59:01 +07 2023
- Loading branch information
Showing
2 changed files
with
38 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,8 @@ | |
interface Environment | ||
{ | ||
public const PROJECT_NAME = 'My Database Packages by HungNG'; | ||
public const VERSION = '3.1.4'; | ||
public const LAST_MODIFIED = '2023-08-13'; | ||
public const VERSION = '3.1.5'; | ||
public const LAST_MODIFIED = '2023-09-26'; | ||
public const AUTHOR_NAME = 'Hung Nguyen'; | ||
public const AUTHOR_EMAIL = '[email protected]'; | ||
public const AUTHOR_URL = 'https://nguyenanhung.com'; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -844,6 +844,42 @@ public function getValue($wheres = '', $fields = 'id', $fieldOutput = '') | |
return $result; | ||
} | ||
|
||
/** | ||
* Hàm lấy giá trị 1 field của bản ghi dựa trên điều kiện 1 bản ghi đầu vào | ||
* | ||
* Đây là hàm cơ bản, chỉ áp dụng check theo 1 field | ||
* | ||
* Lấy bản ghi đầu tiên phù hợp với điều kiện | ||
* | ||
* @param string|array $wheres Giá trị cần kiểm tra | ||
* @param string|mixed $fields Field tương ứng với giá tri kiểm tra, ví dụ: ID | ||
* @param string|mixed $fieldOutput field kết quả đầu ra | ||
* | ||
* @return \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Query\Builder|mixed|null|object | ||
* @see https://laravel.com/docs/6.x/queries#selects | ||
* | ||
* @author: 713uk13m <[email protected]> | ||
* @time : 10/16/18 11:51 | ||
* | ||
*/ | ||
public function getValueOrEmpty($wheres = '', $fields = 'id', $fieldOutput = '') | ||
{ | ||
$this->connection(); | ||
$db = DB::table($this->table); | ||
$db = $this->prepareJoinStatement($db); | ||
$query = $this->prepareWhereAndFieldStatement($db, $wheres, $fields); | ||
$this->logger->debug(__FUNCTION__, 'SQL Queries: ' . $query->toSql()); | ||
$result = $query->first(); | ||
// $this->logger->debug(__FUNCTION__, 'Result from DB => ' . json_encode($result)); | ||
if (!empty($fieldOutput) && ($result !== null) && isset($result->$fieldOutput)) { | ||
return $result->$fieldOutput; | ||
} | ||
|
||
$this->logger->error(__FUNCTION__, 'Không tìm thấy cột dữ liệu ' . $fieldOutput); | ||
|
||
return null; | ||
} | ||
|
||
/** | ||
* Hàm lấy giá trị 1 field của bản ghi dựa trên điều kiện 1 bản ghi đầu vào - Đa điều kiện | ||
* | ||
|