Load more than one instance of the same library

How would I load more than one instance of the same library?

I have this:

$this->load->library('SelectQuery', array('table' => 'items'));

   # Must have categories with images and a parent
   JOIN categories_items
      ON items.id = categories_items.item_id
   JOIN categories
      ON (
         categories_items.category_id = categories.id
         AND categories.in_nav != 0

   # Must have an artist
   JOIN artists
      ON items.artist_id = artists.id

   # Must have at least one image
   JOIN item_images
      ON item_images.item_id = items.id
   items.show != 0
   AND items.quantity > 0
   items.title ASC,
   items.id ASC
   CEILING(100 - items.sale_price/items.price*100) AS percent_off

It seems like once the $this->selectquery variable is used once, it can't be used again without being overwritten.

[eluser]Pascal Kriete[/eluser]
CI includes the class, does some stuff, instantiates it, and stores that object reference in an array. What you get when you say $this->load is that reference. That's done so that you don't actually overwrite the instance when you use it in say a controller and later on in another library.

The easiest thing to do is to just make a new one. Remember, it's already included so all you do is:
$bla = new Name();

Alternatively you could add some sort of restore function to your class that you call to reset all class variables. That way you keep the CI benefits and get to reuse it. That doesn't work if you need multiple instances simultaneously, of course.

Thanks again, inparo.

[eluser]Pascal Kriete[/eluser]
My pleasure Smile .

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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