多对一关系检索每个用户的数据

我正在尝试开发一种功能,每个连接的用户都可以找到他最喜欢的项目或应用程序的列表,除此之外,他还可以为每个最喜欢的应用程序创建文档或常见问题解答的一对多链接。请在下面找到示例

http://img4.mukewang.com/64a955690001c55604520285.jpg

http://img4.mukewang.com/64a9557b0001c1e104490287.jpg

我成功了,每个用户都有自己的应用程序和链接,但这些链接与他们的应用程序无关:并为所有我找不到问题的应用程序复制相同的链接,我将不胜

http://img2.mukewang.com/64a9558f00011d0804730308.jpg

感激你的帮助!这是我与链接-APP关系相关的代码;


链接类


<?php


namespace Carto\cartographieBundle\Entity;


 use Doctrine\ORM\Mapping as ORM;


/**

 * LienDocUserApp

 *

 * @ORM\Table(name="lien_doc_user_app")

 * @ORM\Entity(repositoryClass="Carto\cartographieBundle\Repository\LienDocUserAppRepository")

 */

class LienDocUserApp

{

/**

 * @var int

 *

 * @ORM\Column(name="id", type="integer")

 * @ORM\Id

 * @ORM\GeneratedValue(strategy="AUTO")

 */

private $id;


/**

 * @var string

 *

 * @ORM\Column(name="nomLien", type="string", length=255)

 */

private $nomLien;


/**

 * @var string

 *

 * @ORM\Column(name="lien", type="string", length=255)

 */

private $lien;



/**

 * @ORM\ManyToOne(targetEntity="Application", inversedBy="liensDocUsersApp", cascade={"persist", "merge"})

 * @ORM\JoinColumns({

 *  @ORM\JoinColumn(name="Application_id", referencedColumnName="id")

 * })

 */

private $applications;


/**

 * @ORM\ManyToOne(targetEntity="AuthBundle\Entity\Users", inversedBy="liensDocUsersApp", cascade={"persist", "merge"})

 * @ORM\JoinColumns({

 *  @ORM\JoinColumn(name="User_id", referencedColumnName="id")

 * })

 */

private $fUsers;

应用类


<?php


namespace Carto\cartographieBundle\Entity;


use Carto\cartographieBundle\Repository\ApplicationRepository;

use Doctrine\ORM\Mapping as ORM;

use Symfony\Component\Validator\Constraints as Assert;


/**

 * Application

 *

 * @ORM\Table(name="application")

 * @ORM\Entity(repositoryClass="Carto\cartographieBundle\Repository\ApplicationRepository")

 */

class Application

{


public function __toString() {

    

    return $this->nomApp;

    

}


/**

 * @var int

 *

 * @ORM\Column(name="id", type="integer")

 * @ORM\Id

 * @ORM\GeneratedValue(strategy="AUTO")

 */


蝴蝶不菲
浏览 134回答 1
1回答

动漫人物

您只需要一个条件即可在正确的应用程序的正确链接中显示{% for application in user.applications%}&nbsp; &nbsp; <tr>&nbsp; &nbsp; &nbsp; &nbsp; <td style="width:33%">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <div class="avatar-icon">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="{{application.navigateur}}http: {{application.lien}}" target="blank">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <img src="{{ asset('bundles/carto/images/Applications/'~application.icone~'') }}"></a>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>&nbsp; &nbsp; &nbsp; &nbsp; </td>&nbsp; &nbsp; &nbsp; &nbsp; <td style="width:33%">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {%for lien in user.liensDocUsersApp%}&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {% if lien.applications.id == application.id %}&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <li>{{ lien.nomLien }}</li>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {% endif %}&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {% endfor %}&nbsp; &nbsp; &nbsp; &nbsp; </td>&nbsp; &nbsp; </tr>{% endfor %}
打开App,查看更多内容
随时随地看视频慕课网APP