Phpzendframework data type conversion -- as follows & nbsp; $ result = $ db-& gt; fetchAll (& quot; select * fromalbums & quot ;); in this way, $ result obtains the structure of the Array, and the data access method is $ result [& quot; key & php zendframework data type conversion.
-- As follows
$ Result = $ db-> fetchAll ("select * from albums ");
In this way, $ result is the structure of the Array, and the data access method is $ result ["key"], not a class object.
A new class $ albums = new Albums (); the way to access data is $ albums-> key
What I want to achieve is:
Convert the $ result data structure to the $ albums data structure.
I am using zend studio development tools, zend framework, and I want experts to answer my questions and wait online ......
------ Solution --------------------
Directly added to the $ db class.
$ Db-> key (); isn't it the same?
You need to create another Albums, initialize it, and export the resource handle or result array.
You cannot write this method either. key ()
If there is another method called key2, you can't finish it.
The method for writing a flexible point is getAttr ($ column)
$ Obj-> getAttr ("key2") for calling; not more flexible
Neither can I write ()
------ Solution --------------------
Convert an array to an object? Settype ()
------ Solution --------------------
Zend_Db_Table, Zend_Db_Table_Row, and Zend_Db_Table_Rowset
Http://blog.csdn.net/mengxiangbaidu/article/details/7854093
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service