I think you're understanding the basic idea.
Two paths:
1) IF you intend to have only one [font=monospace]recordStorage[/font] class to serve all other classes, then your [font=monospace]setDataSource[/font] method makes sense. Ideally, however, it would not require the DB table name (as implied here)βinstead, just specify the "record type." That way, you can make changes to the DB structure whenever needed, accommodate records that might require more than one DB table to store, and so forth. The [font=monospace]recordStorage[/font] class should be responsible for deciding what the table name is, based on the type of record requested.
Another suggestion would be to pass the record type at the same time as you pass the id:
$record = $this->storage->GetOneRecord( 'Institute',1 );
The way you have it now, there's a risk of forgetting to call [font=monospace]setDataSource[/font] before a subsequent call, which would result in the wrong record (and wrong record type) being returned.
2) If NOT, then the "data source" can be implicit. This is the approach I take. I have a base [font=monospace]storage[/font] class that accesses the database, and I extend that base class for each record type I have. I might end up with something like:
class storage extends MySQLi{
/* basic database access methods */
}
class instituteStorage extends storage{
/* methods for accessing institute records */
}
class customerStorage extends storage{
/* methods for accessing customer records */
}
// and so forth
Grouping all record storage methods into one class makes more sense at first, but from a practical standpoint, you're going to end up with a BIG class very quickly. Big classes are hard to maintain and easy to be confused by. A single class might work "just fine" for tiny-to-small projects, but separating it all into several smaller classes is definitely the way to go with medium-to-large projects.