We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Binary columns in database

Is Phalcon able to work with BINARY database columns? There is no TYPE_BINARY in

https://github.com/phalcon/cphalcon/blob/master/phalcon/db/column.zep

I need to store UUID v1 as 128 bit integer represented as BINARY(16). Anyone has experience how to do it?

edited Apr '16

It depends on the specific field and RDBMS engine. In general binary column definitions should be avoided with ORM.

This is what I use for MySQL column defined as BIT.

        $query = 'SELECT *, BIN(Active + 0) AS Active FROM VIDEOS WHERE Active = ? ORDER BY ClipID DESC LIMIT 10';
        $result = $this->db->query($query, [1]);
        $result->setFetchMode(\Phalcon\Db::FETCH_OBJ);
        $res = $result->fetchAll();

and how to write a Binary?

 \PDO::PARAM_LOB

in:

    return (bool)$this->connection->execute(
            $sql,
            [
                'collection' => $this->collection,
                'name' => $name,
                'data' => $this->encode($data)
            ],
            [
                'collection' => \PDO::PARAM_STR,
                'name' => \PDO::PARAM_STR,
                'data' => \PDO::PARAM_LOB
            ]
        );

Is not work.!!!!