doctrine

Doctorine check if record exists in database [duplicate]

最后都变了- 提交于 2020-05-17 03:42:14
问题 This question already has an answer here : Doctrine - check if record exists based on field (1 answer) Closed 4 years ago . I would like to check if a record exist in the database. The only thing it needs to return is true or false. I'm now using the following query to get the record. Is the an other command as getResult() to check if the record exists? return $this->createQueryBuilder('u') ->andWhere('u.email = :email AND u.id != :id') ->setParameter('email', $email) ->setParameter('id',

Doctrine 2.5: Unrecognized field (but only in Symfony's prod mode)

拥有回忆 提交于 2020-05-15 07:19:31
问题 So I seem to be plagued by issues that only affect production mode in Symfony and not developer mode. This time, I have a ManyToOne association and I'm trying to fetch only the entities which do not have an association (i.e. they have a NULL value in the database). This works exactly as I'd expect in dev move, but in prod mode, Doctrine throws an "unrecognized field" exception... for a field which absolutely does exist. Here's the relevant part of the entity in question (Page.php): /** * @ORM

Symfony Doctrine ORM CLI Font/Colors not working?

孤者浪人 提交于 2020-05-15 02:16:46
问题 I have been looking online to see how to fix this, and have been unsuccessful. I've actually had this issue for over a year now and have simply just ignored it. Now that I'm doing more doctrine ORM stuff in my Symfony 4.1 project, I would like to know if anyone knows how to fix the font/colors on my Windows 10 machine? Command Line tools: * Powershell - Doesn't show the colors correctly * Command Prompt - Doesn't show the colors correctly * Git CMD - Doesn't show the colors correctly This is

Doctrine column id does not exist on PostgreSQL

筅森魡賤 提交于 2020-05-13 08:59:44
问题 I have been forced into using PostgreSQL . I have read something about it but still it's new and I have no idea why I'm getting this error: SQLSTATE[42703]: Undefined column: 7 ERROR: column t0.id does not exist LINE 1: SELECT t0.id AS id1, t0.user AS user2, t0.email AS ma... I checked that id column exists for thousand times (almost literally). I asked my friend and he told me that there is no auto increment in PostgreSQL and I have to use sequences. I found that Doctrine generates sequences

laravel使用Schema创建数据表

北城以北 提交于 2020-04-27 02:27:34
1、简介 迁移就像数据库的版本控制,允许团队简单轻松的编辑并共享应用的数据库表结构,迁移通常和Laravel的schema构建器结对从而可以很容易地构建应用的数据库表结构。如果你曾经告知小组成员需要手动添加列到本地数据库结构,那么这正是数据库迁移所致力于解决的问题。 Laravel 的Schema门面提供了与数据库系统无关的创建和操纵表的支持,在 Laravel 所支持的所有数据库系统中提供一致的、优雅的、平滑的API。 2、生成迁移 使用 Artisan 命令make:migration来创建一个新的迁移: php artisan make:migration create_users_table 新的迁移位于database/migrations目录下,每个迁移文件名都包含时间戳从而允许 Laravel 判断其顺序。 –table和–create选项可以用于指定表名以及该迁移是否要创建一个新的数据表。这些选项只需要简单放在上述迁移命令后面并指定表名: php artisan make:migration create_users_table –create=users php artisan make:migration add_votes_to_users_table –table=users 如果你想要指定生成迁移的自定义输出路径,在执行make

基于 Redis 的订阅与发布

守給你的承諾、 提交于 2020-04-21 14:26:36
Github 仓库 demo-redis-subscribe 创建项目 $ composer create hyperf/biz-skeleton demo-redis-subscribe dev-master Installing hyperf/biz-skeleton (dev-master 1eaa35a957cf704a5c9959c68e426a614c7598a2) - Installing hyperf/biz-skeleton (dev-master 1eaa35a): Cloning 1eaa35a957 from cache Created project in demo-redis-subscribe > @php -r "file_exists('.env') || copy('.env.example', '.env');" Loading composer repositories with package information Updating dependencies (including require-dev) Package operations: 133 installs, 0 updates, 0 removals - Installing ocramius/package-versions (1.4.0): Loading from

Request a linked field in symfony

可紊 提交于 2020-04-16 02:32:28
问题 I have a page that displays information about a movie. I recover in GET the id of the film. What I would like to do is retrieve the comments for each film (there is a filmId column in my table linked to the primary id of the film table) /** * @Route("/user/film/{id}", name="film") */ public function film(FilmRepository $repo, CommentRepository $comRepo, EntityManagerInterface $em, Request $req, $id) { $film = $repo->find($id); $comments = $comRepo->findBy(array('id' => $id)); return $this-

What is the difference between WITH and ON in Doctrine Join condition type?

*爱你&永不变心* 提交于 2020-04-10 07:41:27
问题 I'm searching for a better explanation about the difference between WITH and ON condition type for the doctrine clausure. I'm finding the documentation about this very poor and I'm still in doubt. 回答1: In my opinion it's kind of a left over from doctrine 1. Back then ON was used to redefine the join conditions of relations, whereas WITH was used to add more join conditions to the default one. Now in doctrine 2 I have never seen a situation where ON can be used. In fact using ON always ends up

Swoft是如何利用注解实现各种功能的

随声附和 提交于 2020-04-07 06:34:42
PHP中的注解 注解(Annotations) 是Swoft里面很多重要功能特别是AOP,IoC容器的基础。 注解的定义是: “附加在数据/代码上的元数据(metadata)。” 框架可以基于这些元信息为代码提供各种额外功能。 以另一个框架PHPUnit为例,注解@dataProvider声明一个方法作为测试用例方法的数据提供器。当PHPUnit框架执行到某一个测试用例方法时,会迭代该数据提供器,并将其返回的数据作为参数传入测试用例方法,为测试用例方法提供一套用例所需的测试数据。 //摘自phpseclib库的单元测试 public function formatLogDataProvider() { return array( array( //该参数会作为$message_log参数传到testFormatLog()测试用例方法中 array('hello world'), array('<--'), //$message_number_log "<--\r\n00000000 68:65:6c:6c:6f:20:77:6f:72:6c:64 hello world\r\n\r\n"//$expected ), array( array('hello', 'world'), array('<--', '<--'), "<--\r\n00000000 68:65:6c:6c:6f

symfony开发步骤简述

眉间皱痕 提交于 2020-04-02 06:50:22
对symfony具体开发也有了一定时间的接触了,下面说一下开发步骤,以备自己以后查看; 1.确定表关系,字段等 2.在相应的模块下的Rescourse下config/Doctrine创建相应的.orm.yml文件,书写数据库表,并指定entity和Repository路径 4.检查书写是否正确:php bin /console doctrine:schema:validate 3.运行命令:php bin/console php bin/console doctrine:generate:entities XXXBundle/Entity/XXXX 产生所需entity实例, 4.运行: php bin /console doctrine:schema:update - -force 更新数据库 5,创建相应的Controller,书写后端逻辑 6.Rescorse/config/routing.yml 书写路由, 完毕。 来源: https://www.cnblogs.com/eenio/p/11227806.html