Saving boolean value in MySql

Hello, I've got a problem with saving boolean flags in MySql with Phalcon ORM.

For storing boolean values MySql uses a tinyint(1) field.

In Version 1.3.1 here tinyint(1) columns were converted to boolean types automatically.

After this bug report those lines were removed.

But there's the question: How can I use boolean types with MySql, PHP true/false constants and Phalcon ORM in my models?


Why don't you cast ? Example of column name is_active:

public function getIsActive()
    return (bool) $this->is_active;

edited Sep '14

Yes, I'm using the following code with casts now in my models. Actually I don't think it's a nice coding style but at least it's working...


use Phalcon\Mvc\Model as MvcModel;
class User extends MvcModel {
    protected $isAdmin;
    public function onConstruct() {
        $this->isAdmin = 0;
    public function isAdmin() {
        return $this->isAdmin == 1 ? true : false;
    public function setIsAdmin($isAdmin) {
        $this->isAdmin = (int) ((bool) $isAdmin);
        return $this;