草庐IT

Doctrine_Record

全部标签

php - 如何使用 doctrine2 创建数据库?

我已经通过docker设置了一个新的开发环境。我有一个symfony2(2.6)应用程序,所以我想使用app/consoledoctrine方法初始化mysql数据库。还在跑$phpapp/consoledoctrine:database:create--if-not-exists我收到此错误消息:[Doctrine\DBAL\Exception\ConnectionException]Anexceptionoccuredindriver:SQLSTATE[42000][1049]Unknowndatabase'local_api'[Doctrine\DBAL\Driver\PDOEx

php - CodeIgniter Active Record 从一个表插入到另一个表

使用codeigniter事件记录语法将数据从一个表插入到另一个表的语法是什么?我尝试了通常的mysqli查询并且它有效,但我想使用CodeIgniterActiveRecord语法来保持一致性。我尝试使用这些CodeIgniterActiveRecord查询,但仍然没有成功:functioninsert_into(){$this->db->insert('table1');$this->db->set('to_column');$this->db->select('from_column');$this->db->from('table2');} 最佳答案

mysql - 如何在 Rails3 的 Active Record 中按日期和年份分组

我正在尝试在rails3中重新创建以下mysql查询selectcount(id),year(created_at),month(created_at)fromtablewherepublished_state='published'groupbyyear(created_at),month(created_at);我试过类似的方法:results=Table.select('count(id),year(created_at),month(created_at)').where('published_stateLIKE?','published').group('year(creat

php - 使用 sparks 和 active record 设置 codeigniter 时出现问题

我在让我的sparks安装与我的codeigniter安装一起工作时遇到问题以下是我采取的步骤:我通过PHPCLI进入了我的codeigniter项目文件夹的根目录,使用以下命令安装sparkphp-r"$(curl-fsSLhttp://getsparks.org/go-sparks)"我使用下面的spark命令安装了事件记录库phptools\sparkinstall-v0.0.2php-activerecord2a。这个命令给了我以下文件夹结构-application-sparks-php-activerecord-0.0.2-config-variables-vendor-sy

php - 使用 Yii Active Record 查找一列的最大值

如何通过YiiActiveRecord找到数据库中某一列的最大值?我可以通过纯sql和createCommand方法来完成,但我想通过ActiveRecord和CDbCriteria类来完成。有什么办法吗? 最佳答案 您需要按如下方式更改选择标准。$model=newModel;$criteria=newCDbCriteria;$criteria->select='max(column)ASmaxColumn';$row=$model->model()->find($criteria);$somevariable=$row['max

mysql - Symfony2 : Doctrine "could not find driver"

两天前,我开始使用Symfony编写一个网络应用程序。现在,我正在尝试使用Doctrine来保存一个新用户(我已经使用命令phpapp/consoledoctrine:generate:entities在我的数据库中创建了一个实体和“链接”表).当我在订阅表单上使用POSTHTTP请求时,Symfony告诉我:couldnotfinddriver500InternalServerError-PDOException我在Google和这里​​找到了很多解决方案,但没有一个有效:/命令php-m给我:...PDOpdo_mysql...我不明白为什么这不起作用,因为Doctrine可以生成

php - Doctrine 2 的 GIS 扩展

我想为我的Doctrine2项目编写一个GIS(地理空间数据)扩展。我知道如何编写简单的自定义函数和类型。为了适应MySQL特殊的存储格式,我需要在检索/存储数据时使用一些SQL函数(GeomFromWKB()和AsBinary())。我找不到一个地方可以告诉Doctrine2这个。在我看来,convertToPHPValue()和convertToDatabaseValue()方法不是正确的地方。 最佳答案 如果你想在doctrine2中调用SQL函数,你可以使用表达式Func来实现但这仅适用于DQL。这里有示例将告诉您如何使用未

php - 有没有更好的方法来处理 Doctrine 代理对象

我有两个以一对一关系链接的类。classClient{.../***@ORM\OneToOne(targetEntity="ClientInfo")*@ORM\JoinColumn(name="id",referencedColumnName="client_id")*/private$info;...publicfunctiondoSomething(){if(!$this->getInfo()instanceofClientInfo){returnfalse;}return$this->getInfo()->doSomething();}...}classClientInfo{..

php - 如何使用 doctrine2 设置初始 auto_increment 值

我使用doctrine2映射器生成我的innoDB(mysql)数据库。如何使用php注释设置我的auto_incrementedid的初始值?这就是我目前为实体类型的id建模的方式。/***@varinteger$_id**@Column(name="id",type="integer",nullable=false)*@Id*@GeneratedValue(strategy="IDENTITY")*/private$_id;我在文档中找到了以下代码,但它看起来好像会使用单独的表来生成ID。/***@Id*@GeneratedValue(strategy="SEQUENCE")*@C

php - 使用 doctrine 2 进行批处理 INSERT IGNORE 的最有效方法

我有一个脚本需要获取数据库中的条目列表,然后迭代那些在另一个表中创建新条目(如果它们不存在)。目前我在做:foreach($entriesas$entry){$newItem=newItem();$newItem->setAttribute($entry->getAttribute());$entityManager->persist($newItem);try{$entityManager->flush();}catch(\Exception$e){if(!strpos($e->getMessage(),'Duplicate')){throw$e;}$entityManager=$t