Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phalcon\Db::FETCH_COLUMN error: Undefined class constant 'FETCH_COLUMN' #10358

Closed
fizzka opened this issue May 15, 2015 · 7 comments
Closed

Phalcon\Db::FETCH_COLUMN error: Undefined class constant 'FETCH_COLUMN' #10358

fizzka opened this issue May 15, 2015 · 7 comments

Comments

@fizzka
Copy link

fizzka commented May 15, 2015

but #1642 tells us constant must be present.

snippet proposed to be valid:

$result = $db->query($sql, $params);
$result->setFetchMode(Phalcon\Db::FETCH_COLUMN);

$allValuesOfColumn = $result->fetchAll();

little workaround for now:

$result = $db->query($sql, $params);
$allValuesOfColumn = $result->getInternalResult()->fetchAll(PDO::FETCH_COLUMN);

upd: add missed getInternalResult =)

@andresgutierrez
Copy link
Contributor

This is fixed in the 2.0.x branch

@fizzka
Copy link
Author

fizzka commented May 15, 2015

but...

php --ri phalcon

phalcon


Web framework delivered as a C-extension for PHP
phalcon => enabled
Author => Phalcon Team and contributors
Version => 2.0.1
Powered by Zephir => Version 0.6.2a

@andresgutierrez
Copy link
Contributor

2.0.x branch has version 2.0.2

@fizzka
Copy link
Author

fizzka commented May 15, 2015

oh, thanks a lot! waiting for release )

@fizzka fizzka closed this as completed May 15, 2015
@sergeyklay
Copy link
Contributor

$sql = "SELECT id FROM users LIMIT 1000";

$result = $this->getDI()->get('db')->query($sql);
$result->setFetchMode(\Phalcon\Db::FETCH_COLUMN);
var_dump($result->fetchAll()); // nothing

Error log:

[Exception] SQLSTATE[HY000]: General error: fetch mode requires the colno argument (File: /.../TestTask.php Line: [86])
#0 [internal function]: PDOStatement->setFetchMode(7)
#1 /.../TestTask.php(86): Phalcon\Db\Result\Pdo->setFetchMode(7)
  1. What is colno ? MySQL/PHP misspelling?
  2. What I do incorrectly?

@sergeyklay
Copy link
Contributor

@fizzka
Copy link
Author

fizzka commented May 15, 2015

colno (column number) - it is an additional param from pdo. default value is 0 - first column.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants