Welcome Guest, Not a member yet? Register   Sign In
getData() -- please explain
#1

[eluser]JPrieto[/eluser]
Lately I have been reading the USER GUIDE
and following some of its examples
to learn and bother less user of this forum

in one of the "Hello World" tutorial

there is a code in the controller as follows:
Code:
<?php
    class Helloworld extends Controller
  {
        function index()
        {
            $this->load->model('helloworld_model');

            $data['result'] = $this->helloworld_model->getData();
            $data['page_title'] = "CI Hello World App!";

            $this->load->view('helloworld_view',$data);
        }
    }
?>

MY QUESTION IS....

Where can I find more info on the getData() tag?
I can't find it in the USER GUIDE.

Anyone knows where in the USER GUIDE I can read up on it?

and how does it differ from ...->get('table');


THANKS
#2

[eluser]drewbee[/eluser]
That is a model. Models are used to manipulate data, regardless of the source (Think databases, files, but not limited too);

On your example above, there should be a model called 'helloworld_model' in the models folder, with a method called getData() which presumably returns a database query.

This is no different then the get('table') setup, and infact you will come to find models tend to be wrappers for active record, at least in the beginning.
#3

[eluser]Dam1an[/eluser]
Whats the link for this tutorial in the user guide? Cause I can't remember coming accross it :-S

The getData is just a function in the helloworld model (or so it would appear from the above code)

Edit: Drewbee beat me... someone always beats me Sad
#4

[eluser]JPrieto[/eluser]
wow -- now i really feel very dumb

you are so right -- it is not a tag .... it is the name of a function (see below)

well, I guess this experience is part of learning.

uhm ... you are very smart (just as I thought from the start)

Many Thanks


Code:
function getData()
        {
            /* Query the data table for every record and row */
            $query = $this->db->get('data');
            
            if ($query->num_rows() < 0)
            {
                show_error('Database is empty!');
            }
      else
      {
                return $query->result();
            }
        }




Theme © iAndrew 2016 - Forum software by © MyBB