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

Phalcon\Mvc\Model::count() return string

In document, count() return int.

Abstract class Phalcon\Mvc\Model — Phalcon 1.3.0 documentation https://docs.phalcon.io/en/latest/api/Phalcon_Mvc_Model.html

public static int count ([array $parameters])

But count() return string.


        $count = Robots::count();


string '2' (length=1)

Is it bug?

Phalcon 1.3.2 (DB: MySQL)


PHP is a weak type language, if a number present as a string, you still can use it as number, and make number operation on it.

Hi, hu2008yinxiang.

If count() returns int described in the document, I want to chek result by strict comparisons.

PHP: PHP type comparison tables - Manual https://php.net/manual/en/types.comparisons.php#type.comparisons-strict



as the document it returns int, mean the result is number value, do you think it is realy matter the number value's type ?


strict comparison work for the mixed returned value, but the Model::count always return a string-type number value. not the mixed-type

Hi, hu2008yinxiang.

This is not realy matter :). I feel a little bad feeling.

I haven't check cphalcon source code deeply, sorry. If the Model::count never returns FALSE, NULL and "", I'll check result by loose comparisons.

If the Model::count always return a string-type, I hope fix the document.


In fact it depends the PDO option used in the connection. You can force phalcon to return int instead of string. It's a PDO thing. By default PDO returns only strings.