override specific block data to a block

Permalink
I'm trying to build a block called "My Favorites". This is so logged in users can add links to a block that will list their favorite links. I have created a table with bID, cName, cPath, and uID. In the controller, I have a select statement to pull the data based off of their user ID...

class MyFavoritesBlockController extends BlockController {
   function getNavigationArray() {
      $u = new User();
      $uID = $u->getUserID();
      $q = "select * from btMyFavorites where uID = $uID ";
      $db = Loader::db();
      $r = $db->query($q);
      return $r->GetArray();
   }
}


The problem I'm having is that it seems to only show the data that was created within that specific block when a new block is added on the site. For instance, if I had one link created at the time of adding a block to a page, it only shows one link. If I add another block to that very same page and add three more links, it will show those three links plus the one previously created, but the earlier block created only shows the one link. How do I override the search on the bID? I think this is where my problem is.

jbsmith969
 
olliephillips replied on at Permalink Best Answer Reply
olliephillips
How many tables does your block use?

You'll need 2 tables to do this, one for your block data, where one row represents each instance of the block on your site, and one for storing the link data by user.

It sounds like you're storing the favorites in the blocks instance table.
jbsmith969 replied on at Permalink Reply
jbsmith969
You're right ollie. Thanks. I need to separate this into two tables. I guess that means I need to build in the code to add/update the second table for the add.php and edit.php. Yay, more learning on the Concrete way to do all of that. :-)