简体   繁体   中英

Phalcon PHP: getter/setter syntax for ->save()/->update()/->create()

I'm a little bit confused after reading the documentation. It mentions that ->save()/->create()/->update() all will implicitly reference getters and setters for model properties if they exist. What's the syntax for this sort of thing? Specifically, what do I do when a property is related to a field in my table with underscores in it's name? An example of what I think should work:

class Events extends \Phalcon\Mvc\Model {
    protected $id;
    protected $event_name;

    public function setEventName($name){
        $this->event_name = $name;
    }
}

Maybe not a direct answer:

For changing column names you can better use: Column mapping then you would not worry about setters/getters.

Besides that AFAIK Phalcon uses magic getters/setters for fields, so if you have $id it will use magic getter for $id or use a $eventsObj->getId() if that method explicitly exist in class.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM