Get datas from a sql request

How i retrieve the data i want from a sql request and display its on a Simple Page plugin page? I created an 'else if()' condition in the show.php page and i wrote those lines.

else if($page == "index-des-sujets"){
$db = get_db();
$requete = $db->query("Select * from {$db->prefix}liste_sujet");

Thanks you for any informations.

The usual way to get records out of the database is to use the Omeka_Db_Table object. This assumes that there is also a model defined.

If I'm following right, you have a model called ListeSujet, corresponding to a table called liste_sujet.

If that is true, something similar to this would get all the records from that table:

$sujet = $db->getTable('ListeSujet')->findAll();


I don't understand why i have to defined a model when i just went to display the data of a database that i create from my own, in SimplePage page. Can someone explain me this.


My db : liste-sujet

I suppose it depends on how your data is set up. If you have a model that extends the Omeka_Record_AbstractRecord class, then the method above will return those objects.

If you just want the raw data, I think it will work to do $db->query($sql)->fetchAll() and then you would loop through the rows that are returned