doctrine

Symfony 1.4 best practice production & development configuration

六月ゝ 毕业季﹏ 提交于 2020-01-10 11:45:11
问题 I'm just getting started with Symfony. I'm using Git/github as a way of managing my project. I've set up two ignores for log and cache which is fine. I now need to set up a production site. At the moment on this small project I've development and production on the same server but with different file locations and databases. e.g. www.example.com/mysymfonyproject_dev/ < development area & www.example.com/mysymfonyproject/ < Live / Production site On server its /homes/sites/example.com/www

Doctrine - or where?

眉间皱痕 提交于 2020-01-10 04:50:27
问题 I have the following query: $query = Doctrine_Query::create() ->from('Member m') ->where("m.type='1'") ->andWhere("m.name LIKE '%$term%'") ->orWhere("m.surname LIKE '%$term%'") ->orWhere("m.company LIKE '%$term%'") ->orderBy('id DESC'); But it's not working like I want — it is ignoring type column. What I need is result set where m.type=1 and some of other fields in this query is LIKE 'something' . 回答1: $query = Doctrine_Query::create() ->from('Member m') ->where('m.type = 1 AND m.name LIKE ?

How do I use a complex criteria inside a doctrine 2 entity's repository?

懵懂的女人 提交于 2020-01-09 08:55:47
问题 Lets say I have a table that holds information about festivals. Each festival has a start and end date. I want to select all the festivals that are live (that happen) on a given date. Meaning, I want to select all the festivals that their start date is before or on a given date, and that their end date is after or on a the same given date. So I went on to the repository class of the festival entity, and created a method to do just that. But the criteria argument "findBy" expects is an array,

Doctrine DBAL and LOAD DATA LOCAL INFILE

微笑、不失礼 提交于 2020-01-06 21:46:49
问题 Both my MySql server and client are running with local-infile=1 . It makes it possible form my to execute queries like these: LOAD DATA LOCAL INFILE /var/data/report.csv INTO TABLE MyTable FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' IGNORE 2 LINES (column1, column2, column3)'; All is good when I log-in to MySql server from the command line and then execute the query. However, when I want to execute the same query with my application that's using Doctrine DBAL and db.driver: pdo_mysql to

Doctrine query returns extra field in result

时光总嘲笑我的痴心妄想 提交于 2020-01-06 20:58:55
问题 I have a Doctrine query; $q = Doctrine_Query::create()->select('s.monthly_volume') ->from('SearchVolume s') ->innerJoin('s.Keywords k') ->where('k.group_id = ?',array($group_id)); I just want it to return the monthly_volume value in the result array. It currently returns monthly_volume and id, I don't want it to return the id in result. 回答1: Doctrine automatically adds the primary key field to the results in almost every type of hydration mode. In a case like this where you want a simple

Doctrine query returns extra field in result

不问归期 提交于 2020-01-06 20:57:49
问题 I have a Doctrine query; $q = Doctrine_Query::create()->select('s.monthly_volume') ->from('SearchVolume s') ->innerJoin('s.Keywords k') ->where('k.group_id = ?',array($group_id)); I just want it to return the monthly_volume value in the result array. It currently returns monthly_volume and id, I don't want it to return the id in result. 回答1: Doctrine automatically adds the primary key field to the results in almost every type of hydration mode. In a case like this where you want a simple

How can I fetch every row where column is not in (array of values) with Doctrine?

戏子无情 提交于 2020-01-06 19:44:08
问题 I'm trying to accomplish something similar to the following SQL, but using the Doctrine API. SELECT * FROM table_name WHERE column_name NOT IN (1, 2, 3); I was thinking of something like this: $entityManager->getRepository($entity)->findBy(array('ID' => array('NOT IN' => array(1, 2, 3)))); ... How far am I? 回答1: You can do this with a DQL: $result = $entityManager->createQuery("SELECT e FROM $entity e WHERE e.ID NOT IN (:ids)") ->setParameter('ids', array(1, 2, 3), \Doctrine\DBAL\Connection:

Doctrine Join DQL

喜你入骨 提交于 2020-01-06 15:53:47
问题 I's like to do a join between 2 tables on a specific ID. At the moment, I have this DQL: $q = Doctrine_Query::create() ->select('e.*, i.itemName, i.itemtypeId') ->from('Model_EventItem e') ->leftJoin('Model_Item i ON e.itemId = i.itemId') ->where('e.eventitemId = ?', $event->eventId) ->orderBy('i.itemName ASC'); The result is empty, although my eventId has a value ... Can you help me please? I there somewhere a tutorial on DQL-joins? I don't get it right with the help of the Doctrine

Generate Uuid manually in constructor or via UuidGenerator annotation

不羁的心 提交于 2020-01-06 15:01:52
问题 I am switching to Ramsey\Uuid and don't know what is the intended way to generate the Uuids. Either as shown in the examples with an anntoation: /** * @var UuidInterface * * @ORM\Id * @ORM\Column(type="uuid", unique=true) * @ORM\GeneratedValue(strategy="CUSTOM") * @ORM\CustomIdGenerator(class="Ramsey\Uuid\Doctrine\UuidGenerator") */ private $id; public function __construct() { } Or manually in the constructor: /** * @var UuidInterface * * @ORM\Id * @ORM\Column(type="uuid", unique=true) */

Exception with Doctrine2 and HYDRATE_SIMPLEOBJECT

廉价感情. 提交于 2020-01-06 14:55:31
问题 As a good practice i'm tring to hydrate an object as small as possible since data is going to be read only (just show the entity in my Twig template). So i've tried HYDRATE_SIMPLEOBJECT hydratation mode but i'm getting this exception: Cannot use SimpleObjectHydrator with a ResultSetMapping that contains more than one object result. How should i interpret this message? By the way, here is the code that throws the exception: protected function getFindAllQueryBuilder() { return $this-