Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Phalcon\Mvc\Model\Resultset::count bad return type

I probably found a bug because you define return type of count function as integer but I'm getting always a string value. Of course I could have something wrong in MSSQL adapter or dialect but I didn't find any function which return count value. Any hint?

I've been noticing this with get-set methods within a model even when the datatype has been set correctly on the database, I've just been casting the type directly in the get method example:

public function getId()
    return (int)$this->id;

All database values appear in PHP as strings. Phalcon doesn't do any type conversion.

Why? Adapter detect correct types for Phalcon\Db\Column so there is no reason do that when you keep values as string. However im talking about functions from Resultset:

public int count () -
public int count () inherited from Phalcon\Mvc\Model\Resultset -

It is documented with integer but i receive string.

Sorry, I misunderstood your question.

What type of string is being returned? Is it a number string like "1" or "1,200" or "1.200"?

edited Aug '14

@quasipickle I'm encountering this currently, you state that value types aren't cast even though this behaviour (I think) should be implemented but even calling a count() as the OP has suggested returns a string

I have a Products model that has a relationship with ProductsPages and calling



string '2' (length=1)

when I'm expecting

int 2


I've found this already reported at GitHub: