草庐IT

symfony-console

全部标签

php - 如何在 Symfony 中构建 Docterine 内部连接查询

我正在做一个Symfony项目,我想为这个SQL创建DoctrineQuery。用户表:列-昵称评论表:列-用户身份,审查,创建于谢谢SELECT`USER`.NICK_NAME,REVIEWS.REVIEW,REVIEWS.CREATED_ATFROMREVIEWSINNERJOIN`USER`ONREVIEWS.USER_ID=`USER`.IDWHEREREVIEWS.MOVIE_ID=625GROUPBYREVIEWS.USER_ID我试过这样的东西$q=Doctrine_Query::create()->select("u.NICK_NAME,r.REVIEW,r.CREAT

php - 从 Symfony 1.4 任务记录 Doctrine 查询

我希望Symfony将我的一项任务执行的DoctrineSQL查询记录到日志文件中,就像Web调试工具栏对非cli代码所做的那样。这可能吗?Symfony版本:1.4.12Doctrine版本:1.2.4这是任务的一些示例代码。我希望SELECT查询的记录方式与从操作调用它时的记录方式类似。classexampleTaskextendssfBaseTask{protectedfunctionconfigure(){parent::configure();$this->namespace='test';$this->name='example';}protectedfunctionexe

php - Symfony 和 Doctrine 中对数据库的查询过多

架构.yml:JobeetCategory:actAs:{Timestampable:~}columns:name:{type:string(255),notnull:true,unique:true}JobeetJob:actAs:{Timestampable:~}columns:category_id:{type:integer,notnull:true}name:{type:string(255)}relations:JobeetCategory:{onDelete:CASCADE,local:category_id,foreign:id,foreignAlias:JobeetJ

php - 我的 Symfony2 应用程序出现语法错误或访问冲突

我无法通过表单创建我的实体,因为我遇到了这个错误:CRITICAL-UncaughtPHPExceptionDoctrine\DBAL\DBALException:"Anexceptionoccurredwhileexecuting'INSERTINTOTask(title,misc,url,attachment,time_estimated,started_at,finished_at,default,deadline,task_priority_id,task_id,project_id,task_category_id,user_id)VALUES(?,?,?,?,?,?,?,?

php - Symfony SQLSTATE[HY000] [2002] 1and1 服务器拒绝连接

我正在尝试在1and1服务器上部署我的symfonyapi。但我无法通过此错误:request.CRITICAL:UncaughtPHPExceptionDoctrine\DBAL\Exception\ConnectionException:"Anexceptionoccuredindriver:SQLSTATE[HY000][2002]Connectionrefused"...我的Symfonyparameters.yml:parameters:database_host:127.0.0.1database_port:3316database_name:myDbNamedatabas

Symfony 3,无实体的查询,但有学说

我创建了一个API系统。一切都是完美的,它可以与DB一起使用弹性。不幸的是,单个功能需要在旧的MySQLDB中添加/编辑/检索一行。我不想随时连接到DB,而只是在需要时。我想使用CreatequeryBuilder,但没有实体。可能吗?看答案您可以使用DBAL进行简单的旧查询,该查询将返回一个数组:getEntityManager()->getConnection();$sql='SELECT*FROMmy_table';$stmt=$conn->prepare($sql);$stmt->execute();var_dump($stmt->fetchAll());die;}}QueryBuil

php - Symfony2 : Unable to use DoctrineExtensions Mysql Year function

到目前为止,我未能成功实现beberleiDoctrineExtensions。我需要MySQLYear()函数。错误是:Expectedknownfunction,got'Year'所以我一定是遗漏了什么。什么?这是我到目前为止得到的:扩展安装在..\vendor\beberlei\lib\DoctrineExtensionsapp/autoload.php内容如下:useDoctrine\Common\Annotations\AnnotationRegistry;$loader=require__DIR__.'/../vendor/autoload.php';$loader->ad

mysql - Doctrine "on update CURRENT_TIMESTAMP"注释 (Symfony2)

我需要为实体中的列添加注释-“更新CURRENT_TIMESTAMP”属性。我该怎么做? 最佳答案 您不能使用自己的列定义:/***@ORM\Column(type="datetime",columnDefinition="DATETIMEonupdateCURRENT_TIMESTAMP")*/private$updatedAt;这个例子是针对MySQL的。请注意,columnDefinition在不同数据库甚至不同版本之间不可移植。 关于mysql-Doctrine"onupdate

php - 缺少主键 id 的值 Doctrine Symfony2

我正在研究symphony2.8.2学说中两个实体之间的连接。我不断收到“主键ID缺失值”这是缺少ID的ID注释。/***@ORM\Id*@ORM\Column(type="integer")*@ORM\GeneratedValue(strategy="AUTO")*/protected$id;这是我的连接:/***@ORM\OneToOne(targetEntity="FYP\BaseDesignBundle\Entity\SessionDesign",inversedBy="user")*@ORM\JoinColumn(name="fcid",referencedColumnNam

php - 如何在 Symfony 3 中正确存储日期时间?

我正在尝试将mysql日期时间存储在Symfony存储库中,但出现错误。尝试了来自网络和此处堆栈的一些建议,但没有任何方法可以消除此错误。这就是我想要做的(为清楚起见,代码被缩写)我的实体字段:/***@var\DateTime**@ORM\Column(name="created",type="datetime")*/private$created;我的repo代码:$reservedays=84;$now=new\DateTime('NOW');$now->modify('+'.$reservedays.'days');$payment=newAppBundle\Entity\Pa