Advertisement
Guest User

Untitled

a guest
Feb 20th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. <?php
  2.  
  3. namespace FrontEndBundleEntity;
  4.  
  5. use DoctrineORMMapping as ORM;
  6.  
  7. /**
  8. * MarcaAuto
  9. *
  10. * @ORMTable(name="marcas_auto")
  11. * @ORMEntity(repositoryClass="FrontEndBundleRepositoryMarcaAutoRepository")
  12. */
  13. class MarcaAuto
  14. {
  15. /**
  16. * @var int
  17. *
  18. * @ORMColumn(name="id", type="integer")
  19. * @ORMId
  20. * @ORMGeneratedValue(strategy="AUTO")
  21. * @ORMOneToMany(targetEntity="ModeloAuto", mappedBy="idMarca")
  22. */
  23. private $id;
  24.  
  25.  
  26. /**
  27. * @ORMColumn(type="string", length=100)
  28. */
  29. private $marca;
  30.  
  31. <?php
  32.  
  33. namespace FrontEndBundleEntity;
  34.  
  35. use DoctrineORMMapping as ORM;
  36.  
  37. /**
  38. * ModeloAuto
  39. *
  40. * @ORMTable(name="modelos_auto")
  41. * @ORMEntity(repositoryClass="FrontEndBundleRepositoryModeloAutoRepository")
  42. */
  43. class ModeloAuto {
  44.  
  45. /**
  46. * @var int
  47. *
  48. * @ORMColumn(name="id", type="integer")
  49. * @ORMId
  50. * @ORMGeneratedValue(strategy="AUTO")
  51. */
  52. private $id;
  53.  
  54. /**
  55. * @var int
  56. * @ORMColumn(name="id_marca", type="integer")
  57. * @ORMManyToOne(targetEntity="MarcaAuto", inversedBy="id")
  58. * @ORMJoinColumn(name="id_marca", referencedColumnName="id")
  59. */
  60. private $idMarca;
  61.  
  62. $em = $this->getDoctrine()->getManager();
  63. $query = $em->createQuery(
  64. 'SELECT a
  65. FROM FrontEndBundle:MarcaAuto a
  66. LEFT JOIN a.id
  67. ORDER BY a.marca ASC'
  68. );
  69.  
  70. $marcasVehiculos = $query->getResult();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement