application/third_party/community_auth/controllers/Examples.php
/**
	 * Get an unused ID for user creation
	 * 
	 * @return  int
	 */
Get an unused ID for user creation

@return  int
Get an unused ID for user creation @return int
private function _get_unused_id()
	{
		$random_unique_int = mt_rand(1200,999999999);
		$query = $this->db->where('user_id', $random_unique_int)
			->get_where( config_item('user_table'));
		if( $query->num_rows() > 0 )
		{
			$query->free_result();
			return $this->_get_unused_id();
		}
		return $random_unique_int;
	}
private function _get_unused_id ( ) { $ random_unique_int = mt_rand ( 1200 , 999999999 ) ; $ query = $ this -> db -> where ( 'user_id' , $ random_unique_int ) -> get_where ( config_item ( 'user_table' ) ) ; if ( $ query -> num_rows ( ) > 0 ) { $ query -> free_result ( ) ; return $ this -> _get_unused_id ( ) ; } return $ random_unique_int ; }
Get an unused ID for user creation
Get an unused ID for user creation
// Create a random user id // Make sure the random user_id isn't already in use // If the random user_id is already in use, get a new number