Data table field Demand_praiseid type varchar default empty string How to convert an array

Source: Internet
Author: User
 // 添加点赞人    public function addPraisePeople($uid,$demand_id){        $demandId['demand_id'] = $demand_id;        $m = D('demand');        $praiseid = $m->where($demandId)->getField('demand_praiseid');            }

One of the demands I posted was that nobody saved me. When I like it, I'm going to take out the Demand_praiseid. This field is converted to an array and the UID is stored in the array and the array is stored in the conversion JSON field.

I haven't done it for a day, and I don't know if I'm trying to make this project too complicated.

Reply content:

 // 添加点赞人    public function addPraisePeople($uid,$demand_id){        $demandId['demand_id'] = $demand_id;        $m = D('demand');        $praiseid = $m->where($demandId)->getField('demand_praiseid');            }

One of the demands I posted was that nobody saved me. When I like it, I'm going to take out the Demand_praiseid. This field is converted to an array and the UID is stored in the array and the array is stored in the conversion JSON field.

I haven't done it for a day, and I don't know if I'm trying to make this project too complicated.

First of all, to understand your problem, you should ask:
The field of a data table is a varchar type, after you get the value of this field in PHP, how do you convert the value of this field to an array?
Second: If you want to convert the contents of Demand_praiseid to an array, this is going to be based on the structure of your demand_praiseid.
PHP has a function of a string-to-array:
Explode (Separator,string,limit)
Parameter Description: separator: Required. Specifies where to split the string.
String: Required. The string to split.
Limit: Optional. Specifies the number of array elements that are returned. Possible values: greater than 0-returns an array containing a maximum of limit elements less than 0-returns an array containing all elements except the last-limit element 0-Returns an array containing an element
I hope I can help you, but I don't seem to understand your needs.

  • Related Article

    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.