doctrine

Symfony Filter not working

社会主义新天地 提交于 2019-12-13 05:48:46
问题 My schema: Poster: actAs: Timestampable: ~ Sluggable: fields:[name] columns: id: type: integer(4) autoincrement: true primary: true name: type: string(255) notnull: true filename: type: string(255) notnull: true approved: type: boolean(1) default: false start_date: type: date notnull: true end_date: type: date notnull: true user_id: type: integer(20) default: 1 attributes: export: all validate: true relations: User: class: sfGuardUser local: user_id foreign: id type: one foreignType: many

Symfony2 Table with 3 entity in Twig

给你一囗甜甜゛ 提交于 2019-12-13 05:17:45
问题 First of all, sorry by advance for my english which is not perfect. I have a problem for days by reporting 3 doctrine entity in a Twig Table template. It's a table for manage stocks at work. I have different materials which have each different sizes. Each couple (1 material + 1 size) got a number as amound to order. So I first created 3 entity : Stock (represent materials) ManyToMany Dimension (represent sizes) Besoin (needs) got a ManyToOne relation with both Stock and Dimension. Then, I

Persisting object with relationship, database not updating

大城市里の小女人 提交于 2019-12-13 04:47:42
问题 I have 2 entities with relationship OneToMany . entity Question: /** * @ORM\OneToMany(targetEntity="Quiz\CoreBundle\Entity\Answer", mappedBy="question", cascade={"persist"}) */ private $answers; entity answer: /** * @ORM\ManyToOne(targetEntity="Quiz\CoreBundle\Entity\Question", inversedBy="answers") */ private $question; Here I try to persist : $em = $this->getDoctrine()->getManager(); $question = new Question(); $answer = new Answer(); $answer2 = new Answer(); $answer->setAnswerText(

Doctrine_Table Vs class That extends from BaseClass

倖福魔咒の 提交于 2019-12-13 04:17:00
问题 I am a little confused in this Doctrine model concept , lets say we a table called "article" Doctrine will generate class called i am using Zend framework and Doctrine 1.2 models/generated/BaseArticle.php models/ArticleTable.php models/Article.php Is it true to call the ArticleTable in the controller in this way $tableArticle = Doctrine::getTable('Article'); then to save it in the Article Object like this $article = new Article(); $fArticles = $tableArticle->getFeaturedArticles(); foreach (

Array not in array for doctrine query

喜夏-厌秋 提交于 2019-12-13 04:08:04
问题 I need to use a condition like array is not in array. I have array which one has two element for search. For example (3,1) NOT IN ((2,3),(1,3),(1,32)) it's work as SQL query in phpmyadmin. But not worked as doctrine query. $em = $this->getDoctrine()->getManager(); $qb = $em->getRepository('FangoUserBundle:User') ->createQueryBuilder('user') ->leftJoin('user.collabInvitationTarget', 'invite') ->where('(:currentUserId, user.id) NOT IN (:inviteArr)') ->setParameter('currentUserId', $this-

Error in Doctrine 2 sandbox

百般思念 提交于 2019-12-13 02:59:16
问题 i am trying to get started with Doctrine 2. and i am reading their intro. i am stuck trying to run D:\Projects\Websites\php\Doctrine\sandbox>doskey doctrine=php d:\resourcelibrary\frameworks\doctrine\bin\doctrine.php $* D:\Projects\Websites\php\Doctrine\sandbox>doctrine --version Doctrine Command Line Interface version 2.0-DEV // from here u can see that doctrine works ... i used doskey to shorten typing D:\Projects\Websites\php\Doctrine\sandbox>doctrine orm:schema-tool:create ./entities

Symfony sfDoctrinePager with multiple tables

瘦欲@ 提交于 2019-12-13 02:51:38
问题 I was wondering how to get this to run. In my application I have a Category table and Product table. I need to have a pager which combines both Categories and Products for display in one list (first categories then products). Is there a way to get this going ? I tried left joining in the pager's query, but doesn't seem to do the trick. 回答1: If you can write a doctrine query to return the complete list of what you want, then the pager will page it. Not sure without a schema how you might write

Telling doctrine how to format DateTime when using native query and resultsetmapping

守給你的承諾、 提交于 2019-12-13 02:43:51
问题 I'm Natively querying for some data using doctrine using the code below: $sql = "SELECT count(type) AS notifications, count(DISTINCT subject) AS users, count(DISTINCT object_activity) AS activities, count(DISTINCT object_activity_relationship) AS relationships, type, min(created) as oldest, max(created) as latest " ."FROM notification n " ."WHERE target_user='".$user->id."' AND notification_read=0 " ."GROUP BY type " ."ORDER BY latest "; $rsm = new \Doctrine\ORM\Query\ResultSetMapping; $rsm-

Dql select in doctrine vs sql query

老子叫甜甜 提交于 2019-12-13 02:03:00
问题 What is the benefit of use DQL in 'select' statement in doctrine vs native sql? e.g $qb = $em->getRepository('repositoryname')->createQueryBuilder('r); $qb->someDqlCondition(); $qb->getQuery()->getResult(); vs $sql = 'string with SELECT sql statement' $query = $em->->createQuery($sql) $query->getResult(); I discuss about it with my colleague and he say that native sql is better. I think that dql give us ability to change database driver.Is there any other benefit of using dql? What about

Why does Doctrine2 do an INNER JOIN for findAll()?

大城市里の小女人 提交于 2019-12-13 01:54:05
问题 I have a User and Company entity. Each User belongs to a Company . Here are my entities (shortened): <?php namespace App\Model\Entity; use Doctrine\ORM\Mapping as ORM; use Doctrine\Common\Collections\ArrayCollection; /** * @ORM\Table(name="user") */ class User { /** * @ORM\Id * @ORM\Column(type="integer", name="user_id") * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @ORM\Column(length=200) */ private $email; /** * @ORM\ManyToOne(targetEntity="Company", inversedBy="users", fetch