Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>A common approach in web frameworks would be to map records onto objects: one record from the database is read into one object, so your result is an Array of Objects. For different tables you need different classes. This is one of the building blocks for the Model View Controller (MVC) pattern used in many web frameworks. </p> <p>For example in Ruby on Rails the Table <code>users</code> is handled by a Class <code>User</code>. You create both using a scaffold.</p> <pre><code>ruby script\generate scaffold user lastname:string link:string joined:date </code></pre> <p>Date, Boolean, String, Text, Decimal, Integer are distinct datatypes here. Unfortunately URLs are not, so I have to use String for the link.</p> <p>You can read users from the database like this:</p> <pre><code>@u = User.find(77) # gives you one object @list = User.find(:all) # gives you an array of User-objects </code></pre> <p>the attribute of the user object have the correct types to work with dates, numbers, etc:</p> <p>if 100.days.ago &lt; @u.joined then ....</p> <p>Logic that is inherent to the data is implemented in the User class.</p> <p>The list of users may be displayed in HTML using a view like this:</p> <pre><code> &lt;h1&gt;Listing Users&lt;/h1&gt; &lt;table&gt; &lt;tr&gt; &lt;th&gt;Lastname&lt;/th&gt; &lt;th&gt;Link&lt;/th&gt; &lt;th&gt;Joined on&lt;/th&gt; &lt;/tr&gt; &lt;% @list.each do |user| %&gt; &lt;tr&gt; &lt;td&gt;&lt;%=h user.lastname %&gt;&lt;/td&gt; &lt;td&gt;&lt;%= link_to "Homepage", user.link %&gt;&lt;/td&gt; &lt;td&gt;&lt;%=h user.joined %&gt;&lt;/td&gt; &lt;/tr&gt; &lt;% end %&gt; &lt;/table&gt; </code></pre> <p>Logic that is inherent to displaying the data is implemented in the view(s). The knowledge which attribute of the object is to be treated as a link or a normal text resides in the view, not in the object itself.</p> <p>Displaying / Outputting the same data as cvs is done by creating a cvs-view.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload