I'm working with PDOStatement->fetchAll() and I need it to return the
Object I specify. I've got it working with individual rows and
PDOStatement->fetchObject(), i'm able to tell it what class to load
the variables into with this function and if I read correctly I should
also be able to do this with fetchAll() also.

page says I should be able to use the $fetch_style outlined on the
fetch() page, but its not very clear hot to specify which class to

For example, this code:
return $queryData->fetchObject(get_class($this));
does exactly what i want it to, puts the variables into the class I
specify so I can handle the data with custom methods..

I need to do the same with a fetchAll. I have it returning with an
anonymous object (called stdClass, the default) but would like to know
how to specify the object to call as above, as I need the flexibility
of custom classes with these result sets also.

I've experimented a little with the fetchAll() method, for example:
return $queryData->fetchAll(PDO::FETCH_CLASS|PDO::FETCH_CLASSTYPE);

return $queryData->fetchAll(PDO::FETCH_CLASS|get_class($this));

but both still only return the stdClass object..

Can someone explain how to do this with fetchAll() a little more clearly?



PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to