direct access to db & loadFileSet question

Permalink 1 user found helpful
1. is there any easy examples for me to start of where i can easily do a "select * from table_name" query in my model/controller?

http://www.concrete5.org/help/building_with_concrete5/developers/mv...

and

http://phplens.com/lens/adodb/docs-active-record.htm...

don't explain much

2. Needed to load files in a certain set, google search points me to loadFileSet() which was broken in v5.3.0 and fixed later. Any explanation and/or example on how to use that function?


Thank you

kutis
 
andrew replied on at Permalink Reply
andrew
1. For direct db access, checking out the blocks themselves is probably the easiest way. Inside your functions, to get access to our ADODB object, just make sure you call

$db = Loader::db();

This will give you a database object that all the ADODB commands in your reference will work on. So, for example

$foo = $db->GetAll('select col1, col2, col3 from mytable where myid = ?', array($myID));

will give you an associative array of all rows from the mytable table where myid is a certain value.

2. There really isn't a good way to get files in a file set via a public API. If you really need a solution you can check blocks/slideshow/controller.php to see how our tables are structured, but in the future we will offer a much cleaner way through the API to get it (rather than querying the table directly with SQL).
kutis replied on at Permalink Reply
kutis
$db = Loader::db()

is what i really needed, and the rests are in the ADODB site. though the active record not really easy to read or use (comparing to the codeigniter active record), the usual $db->SelectLimit() $db->getArray() or $db->query() will suffice.