How to assign typical Zend Db Query Object into Array

3 messages Options
Embed this post
Permalink
BEREGU

How to assign typical Zend Db Query Object into Array

Reply Threaded More More options
Print post
Permalink
Hello,

I'm learning Ajax with Zend Framework, and I just want to make my
typical Zend Db Query Object (fetchAll()ed) to Json encoding ready array.

Can someone help me?

Thank you very much in advance.


Sincerely,

Enkhbilguun Erdenetsogt

[enkhbilguun.vcf]

begin:vcard
fn:Enkhbilguun Erdenetsogt
n:Erdenetsogt;Enkhbilguun
email;internet:[hidden email]
tel;cell:99113638
x-mozilla-html:TRUE
version:2.1
end:vcard


Nick Pack

Re: How to assign typical Zend Db Query Object into Array

Reply Threaded More More options
Print post
Permalink
Enkhbilguun Erdenetsogt wrote:

> Hello,
>
> I'm learning Ajax with Zend Framework, and I just want to make my
> typical Zend Db Query Object (fetchAll()ed) to Json encoding ready array.
>
> Can someone help me?
>
> Thank you very much in advance.
>
>
> Sincerely,
>
> Enkhbilguun Erdenetsogt

You can do (in your controller):

$results = $table->fetchAll()->toArray();

$this->_helper->json($results);

Hope that helps
Shaun Farrell

Re: How to assign typical Zend Db Query Object into Array

Reply Threaded More More options
Print post
Permalink
You can just do Zend_Json::encode($array); to encode and to decode just do Zend_Json::decode($json)

On Thu, Oct 29, 2009 at 6:08 AM, Nick Pack <[hidden email]> wrote:
Enkhbilguun Erdenetsogt wrote:
Hello,

I'm learning Ajax with Zend Framework, and I just want to make my typical Zend Db Query Object (fetchAll()ed) to Json encoding ready array.

Can someone help me?

Thank you very much in advance.


Sincerely,

Enkhbilguun Erdenetsogt

You can do (in your controller):

$results = $table->fetchAll()->toArray();

$this->_helper->json($results);

Hope that helps




--
Shaun J. Farrell
Washington, DC
(202) 713-5241
www.farrelley.com