-
Notifications
You must be signed in to change notification settings - Fork 4
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 #59 from nguyenanhung/v3.2.0-develop
Update destruct models
- Loading branch information
Showing
2 changed files
with
172 additions
and
164 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 |
---|---|---|
|
@@ -10,162 +10,170 @@ | |
* Time: 19:25 | ||
*/ | ||
if (!class_exists('HungNG_CI_Base_Custom_Model_Credentials_model')) { | ||
/** | ||
* Class HungNG_CI_Base_Custom_Model_Credentials_model | ||
* | ||
* @author 713uk13m <[email protected]> | ||
* @copyright 713uk13m <[email protected]> | ||
* | ||
* @property CI_DB_pdo_driver|CI_DB_query_builder|CI_DB_driver $db This is the platform-independent base Query Builder implementation class | ||
*/ | ||
class HungNG_CI_Base_Custom_Model_Credentials_model extends HungNG_Custom_Based_model | ||
{ | ||
const IS_ACTIVE = 1; | ||
const ROLE_PUSH = 1; | ||
const ROLE_PULL = 2; | ||
const ROLE_FULL = 3; | ||
|
||
protected $fieldUsername; | ||
protected $fieldStatus; | ||
protected $fieldRole; | ||
|
||
/** | ||
* HungNG_Basic_Custom_Credentials_model constructor. | ||
* | ||
* @author : 713uk13m <[email protected]> | ||
* @copyright: 713uk13m <[email protected]> | ||
*/ | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
|
||
log_message('info', 'HungNG_CI_Base_Custom_Model_Credentials_model Class Initialized'); | ||
|
||
$this->db = $this->load->database('default', true, true); | ||
$this->tableName = 'credentials'; | ||
$this->primary_key = 'id'; | ||
$this->fieldUsername = 'username'; | ||
$this->fieldStatus = 'status'; | ||
$this->fieldRole = 'role'; | ||
} | ||
|
||
/** | ||
* Function checkCredentials | ||
* | ||
* @param string $username | ||
* | ||
* @return int | ||
* @author : 713uk13m <[email protected]> | ||
* @copyright: 713uk13m <[email protected]> | ||
* @time : 09/03/2021 35:51 | ||
*/ | ||
public function checkCredentials($username = '') | ||
{ | ||
$this->db->select($this->primary_key); | ||
$this->db->from($this->tableName); | ||
$this->db->where($this->fieldUsername, $username); | ||
$this->db->where($this->fieldStatus, self::IS_ACTIVE); | ||
|
||
return $this->db->count_all_results(); | ||
} | ||
|
||
/** | ||
* Function getInfoCredentials | ||
* | ||
* @param string $username | ||
* | ||
* @return array|mixed|object|null | ||
* @author : 713uk13m <[email protected]> | ||
* @copyright: 713uk13m <[email protected]> | ||
* @time : 09/03/2021 40:35 | ||
*/ | ||
public function getInfoCredentials($username = '') | ||
{ | ||
$this->db->select(); | ||
$this->db->from($this->tableName); | ||
$this->db->where($this->fieldUsername, $username); | ||
$this->db->where($this->fieldStatus, self::IS_ACTIVE); | ||
$info = $this->db->get()->row(); | ||
if (empty($info)) { | ||
return null; | ||
} | ||
|
||
return $info; | ||
} | ||
|
||
/** | ||
* Function checkUserRoleIsFull | ||
* | ||
* @param string $username | ||
* | ||
* @return bool | ||
* @author : 713uk13m <[email protected]> | ||
* @copyright: 713uk13m <[email protected]> | ||
* @time : 09/03/2021 41:52 | ||
*/ | ||
public function checkUserRoleIsFull($username = '') | ||
{ | ||
$this->db->select($this->primary_key); | ||
$this->db->from($this->tableName); | ||
$this->db->where($this->fieldUsername, $username); | ||
$this->db->where($this->fieldStatus, self::IS_ACTIVE); | ||
$this->db->where($this->fieldRole, self::ROLE_FULL); | ||
$result = $this->db->count_all_results(); | ||
if ($result) { | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
/** | ||
* Function checkUserRoleIsPull | ||
* | ||
* @param string $username | ||
* | ||
* @return bool | ||
* @author : 713uk13m <[email protected]> | ||
* @copyright: 713uk13m <[email protected]> | ||
* @time : 09/03/2021 42:35 | ||
*/ | ||
public function checkUserRoleIsPull($username = '') | ||
{ | ||
$this->db->select($this->primary_key); | ||
$this->db->from($this->tableName); | ||
$this->db->where($this->fieldUsername, $username); | ||
$this->db->where($this->fieldStatus, self::IS_ACTIVE); | ||
$this->db->where_in($this->fieldRole, array(self::ROLE_FULL, self::ROLE_PULL)); | ||
$result = $this->db->count_all_results(); | ||
if ($result) { | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
/** | ||
* Function checkUserRoleIsPush | ||
* | ||
* @param string $username | ||
* | ||
* @return bool | ||
* @author : 713uk13m <[email protected]> | ||
* @copyright: 713uk13m <[email protected]> | ||
* @time : 09/03/2021 42:58 | ||
*/ | ||
public function checkUserRoleIsPush($username = '') | ||
{ | ||
$this->db->select($this->primary_key); | ||
$this->db->from($this->tableName); | ||
$this->db->where($this->fieldUsername, $username); | ||
$this->db->where($this->fieldStatus, self::IS_ACTIVE); | ||
$this->db->where_in($this->fieldRole, array(self::ROLE_FULL, self::ROLE_PUSH)); | ||
$result = $this->db->count_all_results(); | ||
if ($result) { | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
} | ||
/** | ||
* Class HungNG_CI_Base_Custom_Model_Credentials_model | ||
* | ||
* @author 713uk13m <[email protected]> | ||
* @copyright 713uk13m <[email protected]> | ||
* | ||
* @property CI_DB_pdo_driver|CI_DB_query_builder|CI_DB_driver $db This is the platform-independent base Query Builder implementation class | ||
*/ | ||
class HungNG_CI_Base_Custom_Model_Credentials_model extends HungNG_Custom_Based_model | ||
{ | ||
const IS_ACTIVE = 1; | ||
const ROLE_PUSH = 1; | ||
const ROLE_PULL = 2; | ||
const ROLE_FULL = 3; | ||
|
||
protected $fieldUsername; | ||
protected $fieldStatus; | ||
protected $fieldRole; | ||
|
||
/** | ||
* HungNG_Basic_Custom_Credentials_model constructor. | ||
* | ||
* @author : 713uk13m <[email protected]> | ||
* @copyright: 713uk13m <[email protected]> | ||
*/ | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
|
||
log_message('info', 'HungNG_CI_Base_Custom_Model_Credentials_model Class Initialized'); | ||
|
||
$this->db = $this->load->database('default', true, true); | ||
$this->tableName = 'credentials'; | ||
$this->primary_key = 'id'; | ||
$this->fieldUsername = 'username'; | ||
$this->fieldStatus = 'status'; | ||
$this->fieldRole = 'role'; | ||
} | ||
|
||
public function __destruct() | ||
{ | ||
if ($this->db->conn_id) { | ||
$this->db->close(); | ||
log_message('info', 'HungNG_CI_Base_Custom_Model_Credentials_model Class Destructed'); | ||
} | ||
} | ||
|
||
/** | ||
* Function checkCredentials | ||
* | ||
* @param string $username | ||
* | ||
* @return int | ||
* @author : 713uk13m <[email protected]> | ||
* @copyright: 713uk13m <[email protected]> | ||
* @time : 09/03/2021 35:51 | ||
*/ | ||
public function checkCredentials($username = '') | ||
{ | ||
$this->db->select($this->primary_key); | ||
$this->db->from($this->tableName); | ||
$this->db->where($this->fieldUsername, $username); | ||
$this->db->where($this->fieldStatus, self::IS_ACTIVE); | ||
|
||
return $this->db->count_all_results(); | ||
} | ||
|
||
/** | ||
* Function getInfoCredentials | ||
* | ||
* @param string $username | ||
* | ||
* @return array|mixed|object|null | ||
* @author : 713uk13m <[email protected]> | ||
* @copyright: 713uk13m <[email protected]> | ||
* @time : 09/03/2021 40:35 | ||
*/ | ||
public function getInfoCredentials($username = '') | ||
{ | ||
$this->db->select(); | ||
$this->db->from($this->tableName); | ||
$this->db->where($this->fieldUsername, $username); | ||
$this->db->where($this->fieldStatus, self::IS_ACTIVE); | ||
$info = $this->db->get()->row(); | ||
if (empty($info)) { | ||
return null; | ||
} | ||
|
||
return $info; | ||
} | ||
|
||
/** | ||
* Function checkUserRoleIsFull | ||
* | ||
* @param string $username | ||
* | ||
* @return bool | ||
* @author : 713uk13m <[email protected]> | ||
* @copyright: 713uk13m <[email protected]> | ||
* @time : 09/03/2021 41:52 | ||
*/ | ||
public function checkUserRoleIsFull($username = '') | ||
{ | ||
$this->db->select($this->primary_key); | ||
$this->db->from($this->tableName); | ||
$this->db->where($this->fieldUsername, $username); | ||
$this->db->where($this->fieldStatus, self::IS_ACTIVE); | ||
$this->db->where($this->fieldRole, self::ROLE_FULL); | ||
$result = $this->db->count_all_results(); | ||
if ($result) { | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
/** | ||
* Function checkUserRoleIsPull | ||
* | ||
* @param string $username | ||
* | ||
* @return bool | ||
* @author : 713uk13m <[email protected]> | ||
* @copyright: 713uk13m <[email protected]> | ||
* @time : 09/03/2021 42:35 | ||
*/ | ||
public function checkUserRoleIsPull($username = '') | ||
{ | ||
$this->db->select($this->primary_key); | ||
$this->db->from($this->tableName); | ||
$this->db->where($this->fieldUsername, $username); | ||
$this->db->where($this->fieldStatus, self::IS_ACTIVE); | ||
$this->db->where_in($this->fieldRole, array(self::ROLE_FULL, self::ROLE_PULL)); | ||
$result = $this->db->count_all_results(); | ||
if ($result) { | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
/** | ||
* Function checkUserRoleIsPush | ||
* | ||
* @param string $username | ||
* | ||
* @return bool | ||
* @author : 713uk13m <[email protected]> | ||
* @copyright: 713uk13m <[email protected]> | ||
* @time : 09/03/2021 42:58 | ||
*/ | ||
public function checkUserRoleIsPush($username = '') | ||
{ | ||
$this->db->select($this->primary_key); | ||
$this->db->from($this->tableName); | ||
$this->db->where($this->fieldUsername, $username); | ||
$this->db->where($this->fieldStatus, self::IS_ACTIVE); | ||
$this->db->where_in($this->fieldRole, array(self::ROLE_FULL, self::ROLE_PUSH)); | ||
$result = $this->db->count_all_results(); | ||
if ($result) { | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
} | ||
} |
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