小编Yas*_*ekh的帖子

Symfony2递归查询构建器

我有一个数据表,其中包含媒体,文档,PDF和文件夹列表.与Google云端硬盘相同,我想在数据表的顶部显示痕迹.数据表反映了通过jQuery点击任何文件夹时的更改.除了面包屑外,所有的东西都准备好了.我有当前打开的文件夹的ID,但我不知道如何从根到当前文件夹获取层次结构.

目前它给我父ID和名称而不是整个层次结构.

注意: - 列之间没有关系,因为它在同一个表中.
实体字段: -id, nameDisplay, parentId

实体定义: -

/**
 * driveall
 * @ORM\Table(name="Driveall")
 * @ORM\Entity(repositoryClass="DriveBundle\Repository\DriveallRepository")
 */
class Driveall
{
    /**
     * @var int
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @var string
     * @ORM\Column(name="Name_Display", type="string", length=255)
     */
    private $nameDisplay;

    /**
     * @var int
     * @ORM\Column(name="ParentID", type="integer")
     */
    private $parentID;

    /**
     * Get id
     * @return int
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set nameDisplay
     * …
Run Code Online (Sandbox Code Playgroud)

php doctrine hierarchy recursive-query symfony

9
推荐指数
1
解决办法
651
查看次数

试图在json_decode中获取非对象的属性

我是JSON的新手,我有一个以数据库形式从数据库中检索到的json对象

Array
(
    [0] => stdClass Object
        (
            [id] => 1
            [data] => {"vehicle":[{"year":"2000","make":"Ac","model":"Aceca","acquired_year":"2016","acquired_month":"2","use":"Business","distance_driven_to_work_or_school":"2","distance_driven_manually":"10000"}],"first_name":"ADAS","last_name":"DSADSADA","email":"asddsa@sda.com","phone":"dsasasa","postal_code":"","drivers":[{"name":"ssada","birth_year":"2016","birth_month":"2","birth_day":"2","gender":"female","martial_status":"Single","license_number_provided":"yes","license_number":"asddasdas","license_type":"","training_completed":"","years_been_listed_on_auto_policy_in_north_america":"No Previous Experience","license_suspensions":"","accidents":"Select","convictions":"Select","cancellation_reason":"","cancellation_year":"","cancellation_month":"","cancellation_day":""}],"considering_renters_to_reduce_rate":"yes","install_winter_tires":"no","park_in_private_driveway":"yes","willing_to_install_device":"no","years_insured_with_current_company":"4 Years","how_heard_about_us":"asdaa"}
            [date] => 2017-11-20 18:17:52
            [status] => 0
        )

)
Run Code Online (Sandbox Code Playgroud)

现在,当我尝试使用json_decode将其转换为数组时,我正在尝试获取非对象的属性这里是我的代码

<?php
    echo "<pre>";
    print_r($quotes);  //works fine uptil here
    $data = json_decode($quotes->data,true);//the error line
    echo "<pre>";
    print_r($data);
?>
Run Code Online (Sandbox Code Playgroud)

我尝试了几种方法,但它没有工作我尝试了一些其他的解决方案,以及最终得到错误任何帮助?

php json

0
推荐指数
1
解决办法
2496
查看次数

标签 统计

php ×2

doctrine ×1

hierarchy ×1

json ×1

recursive-query ×1

symfony ×1