• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Loop -> loading same model different configs


I'm building an application that pushes files to dropbox for multiple users. Now I have a little problem. I have a cron that pushes new files to the dropboxes of users. So I loop trough all users and select the files that should end up in their folders. I have a library that can be loaded with the oauth details for every user. So every time the loop starts with an other user I have to reload the model with new access tokens. The problem is that Codeigniter doesn't load the new access tokens. So it will always use the tokens of the first user in the loop.

here is a little example of how it works:

foreach($users as $key => $user){
if(!empty($user['oauth_token']) && !empty($user['oauth_token_secret'])) {
  $params = $this->config->item('dropbox_api');
  $params['access']['oauth_token']        = urlencode($user['oauth_token']);
  $params['access']['oauth_token_secret']  = urlencode($user['oauth_token_secret']);
  $this->load->library('dropbox', $params);


Is there a way to unload the model each time a new loop item starts?

Thanks a lot!

Check if your dropbox-library has an initialize method. If it was properly coded then it'll have such a function which you can use to set config-options after loading the library.

Otherwise you may want to create an initialize-method in your dropbox-library to overwrite these settings.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.