Hi!
Situation
I'm using MySQL and Phalcon 2.0.9 and have this snippet in my Models\Base:
    /**
     * @param string $sql
     * @param array  $params
     *
     * @return Resultset\Simple
     */
    public static function findByRawSql($sql, array $params = [])
    {
        $self = new static;
        try {
            /**
             * @type \Phalcon\Db\Adapter\Pdo $conn
             * @type \Phalcon\Db\Result\Pdo  $query
             */
            $conn   = $self->getReadConnection();
            $query  = $conn->query($sql, $params);
            $result = new Resultset\Simple(null, $self, $query);
        }
        catch (\PDOException $e) {
            return false;
        }
        return $result;
    }
What i do
Then i do in my Models\User:
$friends = static::findByRawSql('CALL GetUserFriends(:id)', ['id' => $this->id]);
But have PDOException:
SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the
PDO::MYSQL_ATTR_USE_BUFFERED_QUERYattribute.
Solvings and problems
I've googled about this and PDO::MYSQL_ATTR_USE_BUFFERED_QUERY doesn't help. If i do fetchAll then i can't use Resultset.
Plus, i can't explain this case:
- Send request to my site – in controller do: 
$friends = static::findByRawSql("CALL GetUserFriends(:id)", ["id" => $this->id]);– all is OK – array of arrays with users data - Repeat step no.1 – all is OK – same
 - Repeat step no.1 one more time (third) – FAIL – empty array.
 
Repeats only if i use findByRawSql – other requests to databse working everytime and returning same values.
Questions
So my questions are simple:
- How can i use Resultset and not getting into this error?
 - Why PDO configuration doesn't work?
 - Why findByRawSql returns different empty result every third query? o.0