Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
- /**
- * Users Model
- *
- * @package KOW Manager
- * @author Jeff Davidson
- * @version 1.0.0
- */
- class Users_model extends CI_Model
- {
- function __construct()
- {
- parent::__construct();
- }
- /**
- * Check if username available for registering
- *
- * @param string
- * @return bool
- */
- public function is_username_available( $username )
- {
- $this->db->where( 'username', $username );
- $query = $this->db->get( $this->master_model->users_table );
- return $query->num_rows() == 1 ? FALSE : TRUE;
- }
- /**
- * Check if email available for registering
- *
- * @param string
- * @return bool
- */
- public function is_email_address_available( $email_address )
- {
- $this->db->where( 'email_address', $email_address );
- $query = $this->db->get( $this->master_model->users_table );
- return $query->num_rows() == 1 ? FALSE : TRUE;
- }
- /**
- * Create new user
- *
- * @param string
- * @param string
- * @param string
- * @param string
- * @param string
- * @param string
- * @return integer
- */
- public function create_user( $username, $password, $password_hash, $first_name, $last_name, $email_address )
- {
- $this->db->set( 'username', $username );
- $this->db->set( 'password', $password );
- $this->db->set( 'password_hash', $password_hash );
- $this->db->set( 'first_name', $first_name );
- $this->db->set( 'last_name', $last_name );
- $this->db->set( 'email_address', $email_address );
- $this->db->insert( $this->master_model->users_table );
- if ( $this->db->affected_rows == 1)
- {
- $user_id = $this->db->insert_id();
- return $user_id
- }
- else
- {
- return 0;
- }
- }
- /**
- * Create user profile
- *
- * @param integer
- * @return void
- */
- public function create_user_profile( $user_id )
- {
- $this->db->set( 'user_id', $user_id );
- $this->db->insert( $this->master_model->user_profiles_table );
- if ( $this->db->affected_rows() == 1 )
- {
- return TRUE;
- }
- else
- {
- return FALSE;
- }
- }
- /**
- * Create user registration
- *
- * @param integer
- * @return void
- */
- public function insert_user_registration_details( $user_id, $registration_ip_address, $registration_key, $registration_date )
- {
- $this->db->set( 'user_id', $user_id );
- $this->db->set( 'registration_ip_address', $registration_ip_address );
- $this->db->set( 'registration_key', $registration_key );
- $this->db->set( 'registration_date', $registration_date );
- $this->db->insert( $this->master_model->user_registrations_table );
- if ( $this->db->affected_rows() == 1 )
- {
- return TRUE;
- }
- else
- {
- return FALSE;
- }
- }
- }
- /* End of file users_model.php */
- /* Location: ./application/modules/users/models/users_model.php */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement