it's working different in cake.
You can call
$this->SomeModel->read(null, 1); // 1 is an id
Then You can read/write particular field this way:
$this->SomeModel->data["SomeModel"]["name"] = "new_name";
$this->SomeModel->save();
I don't this it works with getting more than one element (via
Model::find())
On 6 Sty, 05:29, frmdstryr <frmdst...@gmail.com> wrote:
> When I was learning php classes we made a model object for each type
> of data we had. Each model would have crud from another class and then
> model specific functions & attributes. For example i would have:
>
> class Person extends Crud {
> var $first_name;
> var $last_name;
>
> static function getperson{
> return Crud::get(people,$sql);
> }
>
> function full_name() {
> return $this->first_name . ' '. $this->last_name;
> }}
>
> class Crud {
> // crud
> static function get() { sql stuff; return mysql_rows}
> static function delete() {sql stuff; }
> }
>
> something like that, but anyways we would instantiate each item
> returned from the getallPeople() into a person object and then if i
> wanted to get the full name of the person i would just type:
>
> $person = Person::getperson(id); //creates person object
> $person->full_name(); // use object function
>
> this made it really easy because if i wanted to add something to the
> person all i had to do was change the Person object model. I cant get
> this to work with cakephp models. What do i need to do for this to
> work or do I not understand cakephp's models & MVC right?
No comments:
Post a Comment