Welcome Guest, Not a member yet? Register   Sign In
About User Guides
#1

[eluser]Unknown[/eluser]
I am just confused on where I will type the examples in the USER GUIDE manual.
example on DATABASE CLASS, where I will type the examples presented there?

is in the MODELs folder?

Code:
$query = $this->db->query('SELECT name, title, email FROM my_table');

foreach ($query->result() as $row)
{
    echo $row->title;
    echo $row->name;
    echo $row->email;
}

echo 'Total Results: ' . $query->num_rows();

Will I type this code on MODEL?

Code:
$query = $this->db->query('SELECT name, title, email FROM my_table');

Then I will type this in VIEW?

Code:
foreach ($query->result() as $row)
{
    echo $row->title;
    echo $row->name;
    echo $row->email;
}

echo 'Total Results: ' . $query->num_rows();

Thanks for the HELP!

Im really very noob on this... so please be patient.
THanks
#2

[eluser]whitey5759[/eluser]
The user guide is just showing you, in a very brief manner, how to use the various classes. In terms of actually taking that code and using it in an MVC site, some logic is required.

The select and getting back of results from the DB should be done in the Model inside an appropriate function (let's call it getPeople()). This function would return either an object (say an instance of a class called Person), or an associative array of results (personally I use classes, but it's personal preference.

The getPeople() function in the Model would be called by the Controller. The Controller would take these results and then pass them to the View. The View would then display the results appropriately.
#3

[eluser]Unknown[/eluser]
Yes that I know, I am just more on confirming that the example is referring to the user understands the pre requisites on the user guide! meaning he understands fully the MVC.

Thank you for the reply!




Theme © iAndrew 2016 - Forum software by © MyBB