cphalcon icon indicating copy to clipboard operation
cphalcon copied to clipboard

[Phalcon Pdo] Strange error when I try to fetch result as column

Open oswebex opened this issue 8 years ago • 3 comments

I can't fetch result as column, but if directly use PDO then the result is right. And I got a strange error.

SQLSTATE[HY000]: General error: colno must be an integer

Provide minimal script to reproduce the issue

$list = $this->db
  ->fetchAll('SELECT id FROM tbl WHERE status = -2', \Phalcon\Db::FETCH_COLUMN);

// or

$result = $this->db->query('SELECT id FROM tbl WHERE status = -2');
$result->setFetchMode(\Phalcon\Db::FETCH_COLUMN);
$list = $result->fetchAll();

// directly PDO work well
$list = $this->db->getInternalHandler()
  ->query('SELECT id FROM tbl WHERE status = -2')
  ->fetchAll(PDO::FETCH_COLUMN);

Details

  • Phalcon version: 3.3.2
  • PHP Version: 7.2.3 (https://packages.sury.org/php)
  • Operating System: Debian GNU/Linux 9.4 (stretch) x86_64
  • Installation type: installing via package manager (https://packagecloud.io/phalcon/stable/debian)
  • Zephir version (if any): 0.10.7-2917ebe8ae
  • Execute: Cli
  • Other related info (Database, table schema): MariaDB 10.1, InnoDB

oswebex avatar Mar 12 '18 21:03 oswebex

error still take place

subdigger avatar Feb 21 '20 13:02 subdigger

@subdigger I will try to confirm this, this weekend with a test. Thanks for the heads up.

niden avatar Feb 21 '20 16:02 niden

Resolved in https://github.com/phalcon/cphalcon/pull/14869

Thanks for reporting this @ioscars

niden avatar Feb 23 '20 18:02 niden