PHP zendframework Data type conversion, how to solve

Source: Internet
Author: User
Tags zend framework
PHP zendframework Data type conversion
--as follows
$result = $db->fetchall ("SELECT * from albums");
In this way $result is the structure of array arrays, the way to access the data is $result["key"], not the object of the class

New Class $albums = new albums (), so the data is accessed $albums->key

The effect I'm going to achieve is:

Transform the data structure of $result into $albums

I use Zend Studio development tools, Zend Framework frame, little brother just learn PHP, I hope the master answer my questions, online and so on ...

------Solution--------------------
Add directly to the $db class.
$db->key (); it's not the same.
You get a albums, and you initialize it, you pass the resource handle or the result array.
You can't write this way either. Key ()
In case there's a name Key2, you can't finish it.
The way to write a flexible point is called getattr ($column)
Called when $obj->getattr ("Key2") is not more flexible

I would not have written ()
------Solution--------------------
Convert an array to an object? Settype ()
------Solution--------------------
Zend_db_table, Zend_db_table_row, Zend_db_table_rowset
http://blog.csdn.net/mengxiangbaidu/article/details/7854093
  • Contact Us

    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

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.