CodeIgniter Forums
User Interface Model - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: User Interface Model (/showthread.php?tid=21956)



User Interface Model - El Forum - 08-25-2009

[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_Authentication_Database_Class


User Interface Model - El Forum - 08-25-2009

[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.


User Interface Model - El Forum - 08-25-2009

[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.


User Interface Model - El Forum - 08-25-2009

[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');