Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID

Class Model: trying to understand how things work

edited March 2013 in Framework

I have

namespace properties;

class Properties extends \Model {

    public $table = 'properties';

    static function individual ($title = '') {
        return Properties::query ()
            ->where ('title', $title)
            ->where ('on_hold=0')
            ->fetch ();


If I do $p = new properties\Properties ($this->params[0]); the result is an object.

However, if I do

$p = new properties\Properties;
$property = $p->individual (urldecode ($property_title));

the result is an array and $property[0] corresponds to the object in the first example.

What function in Model is $p = new properties\Properties ($this->params[0]); calling?

Forgive me if this indicates my ignorance.


  • edited March 2013

    Checkout the Model.php lib file:

    Your first example uses the _construct() with the vals set, so it retrieves a single object and returns it. If vals are unset it's defaulted to false and it simply returns a new object.

    Your individuals() function, is using the fetch() function. If you look at line 728 of Model.php the fetch() function returns an array of objects.

    Just below that, single() returns the first matched object.

    Sorry for no code in examples, I'm on my phone. Hopefully it helps explain though.

  • Thanks. Yes, that's helpful.

Sign In or Register to comment.