doctrine

How to use Doctrine_RawSql for a fulltext search and sorting by relevance

旧街凉风 提交于 2019-12-23 01:21:07
问题 I'm trying to get fulltext searches to be sorted by relevance in a Doctrine_RawSql query. This code will perform the search: $q = new Doctrine_RawSql(); $q->select('{p.*}') ->from('cms_page p') ->where('match(p.content) against (?)', $user_query) ->addComponent('p', 'CmsPage p'); This will execute. I would like the results to be sorted by relevance The real sql would have to look something like: select p.id, match(p.content) against (?) as score from cms_page as p order by score desc; So I

Do I need to hack ZendFramework1.10.8/Doctrine1.2.2 to get model generated?

旧城冷巷雨未停 提交于 2019-12-22 16:46:05
问题 I've started reading on zend framework and it's use with Doctrine and have implemented a small project to grasp the understanding.I've come to a point where i needed my model generated as in having a generate script like the one suggested in Doctrine 1.2.2 pdf manual.After few unsuccessful attempts like Class 'sfYaml' not found in G:\php_document\zendworkspace\BookingManager\library\doctrine\Doctrine\Parser\Yml.php on line 80 i've googled and found out what people are doing about that. To me

Do I need to hack ZendFramework1.10.8/Doctrine1.2.2 to get model generated?

Deadly 提交于 2019-12-22 16:44:04
问题 I've started reading on zend framework and it's use with Doctrine and have implemented a small project to grasp the understanding.I've come to a point where i needed my model generated as in having a generate script like the one suggested in Doctrine 1.2.2 pdf manual.After few unsuccessful attempts like Class 'sfYaml' not found in G:\php_document\zendworkspace\BookingManager\library\doctrine\Doctrine\Parser\Yml.php on line 80 i've googled and found out what people are doing about that. To me

Zend 1.11.11 Doctrine 2.1.2 initialising of associative proxy entities

大城市里の小女人 提交于 2019-12-22 16:36:43
问题 I am having this strange issue with an associative entity being a proxy class and its methods always returning null. I hope someone can shed a little light on the subject because it's driving me insane. I am calling this code: $arrRoleResources = $em->getRepository("AJFIT\Entity\UserRoleResources")->findAll(); foreach($arrRoleResources as $roleResource) { $name = $roleResource->getRoleFk()->getName(); } The $name will always be null even though when I debug the code it initializes the proxy

How to map and use a DB View from Doctrine2

℡╲_俬逩灬. 提交于 2019-12-22 13:55:38
问题 I have a view on nomencladores schema called obtenerPaisesPorFabricanteProductoSolicitud . This is the content for the view: SELECT ps.id AS psid, ps.nombre, fps.id AS fpsid FROM ( ( nomencladores.pais ps JOIN nomencladores.pais_fabricante_producto_solicitud pfps ON ((pfps.pais_id = ps.id)) ) JOIN negocio.fabricante_producto_solicitud fps ON ( ( pfps.fabricante_producto_solicitud_id = fps.id ) ) ); I'm trying to map the view as follow: use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity * @ORM

Symfony2 add event listener dynamically

倾然丶 夕夏残阳落幕 提交于 2019-12-22 09:44:36
问题 How would you add an event listener (in my case it's a doctrine event) dynamically to the kernel without using services.yml pattern? 回答1: I found the answer myself after doing some digging into the vendor directory and appProdProjectContainer.php file. If you want your events to be registered with event manager you have to specify the tags in your services.yml for the events that you want this to trigger for like: event_listener: class: Company\MyBundle\Listener\MyListener arguments: [

Register custom Doctrine type in Symfony4

自古美人都是妖i 提交于 2019-12-22 09:44:05
问题 So I have this custom Doctrine type namespace App\Doctrine\Types; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\TextType; class MyType extends TextType { private $prefix=''; public function getName() { return 'my_type'; } public function setPrefix(string $prefix) { $this->prefix=$prefix; } } I registerd in in the config/packages/doctrine.yml: doctrine: dbal: types: my_type: App\Doctrine\Types\MyType Then in Kernel boot() I'm trying to add some parameters to this type:

Logical OR in doctrine2 getRepository->findBy()

﹥>﹥吖頭↗ 提交于 2019-12-22 09:18:14
问题 How can write query like in doctrine2 SELECT * from table where field = value1 or field = value2 I found something like $em->getRepository('myentitity') ->findBy( array('field' => 'value1','field'=>'value2'), // $where ); But I think it is AND .. Please suggest me Thanks 回答1: try this $em->getRepository('myentitity') ->findBy( array('field' =>array( 'value1','value2')) // $where ); If you pass an array of values Doctrine will convert the query into a WHERE field IN (..) query automatically:

How to JOIN without a relationship in Doctrine?

我与影子孤独终老i 提交于 2019-12-22 08:12:57
问题 I have an entity Log (table log ) with members resourceType and resourceId (with columns resource_log and resource_id ). The resourceType can e.g. Order (for actions on orders, e.g. status changes ) or Whatever (for Whatever related actions). There is no relationships (neither in Doctrine, nor in the database) between the Log and the "resource" entities/tables. Now I want to select only the Log s, that are related to Order s with myOrderProperty = "someValue" . That means: SELECT * FROM `log`

Symfony 3.3 injecting repositories into services

我与影子孤独终老i 提交于 2019-12-22 08:01:25
问题 I have a bundle which is held in a private Satis repository as its entities and repositories are shared between multiple application. The rest of the applications that consume that bundle are Symfony 2.7 and 2.8 applications. I'm working on a new application and the requirement is to use Symfony 3.3. In the symfony 3.3 application I have tried this in my services.yml: # Learn more about services, parameters and containers at # http://symfony.com/doc/current/service_container.html parameters: