Welcome Guest, Not a member yet? Register   Sign In
User Interface Model
#1

[eluser]renownedmedia[/eluser]
My first contribution to the Ignited Code forum!

Here is a model I built which I've been using for all of my websites which have a table of users. You can specify the names of the table and columns using a config file. Every time you access the model functions (update, modify, etc) you can specify which columns you want to work with.

Here's an example of the implementation:

Code:
$new_user_id = $this->rm_user->create('username' => 'tlhunter', 'password' => 'pass');
$this->rm_user->set($new_user_id, 'username', 'monkey');
$this->rm_user->set($new_user_id, array('username'=>'banana', 'password'=>'will_be_encrypted'));

$user_id = $this->rm_user->auth('tlhunter', 'password');
if ($user_id) {
  $this->session->set_userdata($this->rm_user->get($user_id, array('username', 'email')));
} else {
  #invalid login
}

And here is the URL to the full thing:
http://renownedmedia.com/codevault/User_...base_Class
#2

[eluser]wiredesignz[/eluser]
Good work.

Try not using $this->config->item() like you would use an array, it is actually a method call (as you know) and is very slow.

Grab the entire config array once only and store it locally.
#3

[eluser]renownedmedia[/eluser]
Thanks for the heads up, didn't realize the overhead doing it this way.

How do you return an array of all the config items? Didn't see it when I looked at the user guide.
#4

[eluser]wiredesignz[/eluser]
Force config to use an index when loading your config array from file.
Code:
$this->config->load('settings', TRUE);

Then a single call will retrieve the entire array.
Code:
$settings = $this->config->item('settings');




Theme © iAndrew 2016 - Forum software by © MyBB