草庐IT

具有类似于 ADO.NET Entity Framework 代码优先功能的 PHP ORM 框架?

我正从.NET世界回到PHP进行一些副业项目。作为一种语言,我对PHP感到很满意,但在当今可用的许多PHP框架中有点迷失。在我使用PHP的日子里,我们只是编写SQL查询,所以我不知道今天的PHP在ORM方面有什么可能,所以才有这个问题。我习惯于使用ADO.NETEntityFrameworkCodeFirst创建我的数据库模型,我喜欢这种方法,所以我正在寻找具有类似功能集的PHPORM框架。 最佳答案 如果我没理解错的话,您正在搜索具有AR和CRUD之类的框架。我想几乎所有比较著名的PHP框架都有这个选项。无论如何,我正在使用Yii

php - 从字符串设置 Symfony2 中的日期时间和时间

在我的实体中,我有两个字段,一个是DateTime类型,另一个是Time类型。我正在尝试这样做:$time="05:45";$date="01-09-2015"$entity=newEntity();$entity->setDate(new\DateTime($date));$entity->setTime($time);在这两种情况下,Symfony都告诉我代码有格式问题。我也试过:->setDate(newDatetime($date));->setDate(DateTime::createFromFormat($date,'d-m-Y));->setTime(strtotime(

php - html_entity_decode 不解码 ASCII

这是我的代码:$string='It';$string=html_entity_decode($string);echo$string;它应该回显“It”,但它只是回显ASCII码。我使用了错误的功能吗?我还尝试了htmlspecialchars_decode,它没有任何改变。 最佳答案 这些不是有效的实体实际上,它们在HTML4中是有效的(我想HTML5也是如此),但在这种情况下,实体需要以分号结尾以便PHP识别它们:$string='It';htmlspecialchars_decode()只解码

php - XML 解析错误 : XML or text declaration not at start of entity

我的rss.php中有这个错误XMLParsingError:XMLortextdeclarationnotatstartofentityLocation:http://blah.com/blah/blah/site/rss.phpLineNumber1,Column3:andthisisshownunderneaththeerrorxzfbcbcxv123Descriptionfortherssfeed----------------^显示在页面左侧和?xml行之间。在我的rss.php中有';?>';?>';$sql="SELECT*FROM$_NEWS_TABLELIMIT5";

php - Magento 集合在不同模块之间加入

我一直在开发一个自定义模块,该模块具有管理员后端。到目前为止,它一直运行良好,就像客户模块一样,但现在我坚持这样做。我的自定义表保存了客户ID,我可以在网格的每一行中显示客户名称。到目前为止,我可以出示身份证件,我知道我应该准备收藏品,但我没有头绪。如果我使用join它只适用于同一模块的模型。我试过这个:$collection=Mage::getModel('mymodule/mymodel')->getCollection()->getSelect()->join('customer_entity','main_table.customer_id=customer_entity.en

php - Symfony/Doctrine "refers to the owning side field which does not exist"- 但类中存在属性

SeUserProgress和SeUser。SeUserProgress表为每个用户保存多个条目。这通过以下两个映射表示。类:SeUserProgress/***@ORM\ManyToOne(targetEntity="SeUser",inversedBy="progress")*@ORM\Column(name="user_id",type="integer",nullable=true)*/private$user;类别:SeUser/***@ORM\OneToMany(targetEntity="SeUserProgress",mappedBy="user")*/private$

php - 如何获取学说实体属性的类型

实际上我有一个学说实体,我需要动态填充它的属性。我希望能够做这样的事情:$entity=newEntity();$reflect=newReflectionClass($entity);//$fieldsisanarraywhihchcontaintheentitynameasthearraykeyandthevalueasthearrayvalueforeach($fieldsas$key=>$val){if(!reflect->hasProperty($key)){var_dump('theentitydoesnothaveasuchproperty');continue;}if(

php - symfony2 ContextErrorException : Catchable Fatal Error: Object of class Proxies\__CG__\. ..\Entity\... 无法转换为字符串

我遇到了一些奇怪的事情:我通过app/consoledoctrine:generate:entity创建了三个doctrine实体:类别用户发布我建立了关系,并且一切都与fixtures数据一起正常工作(app/consoledoctrine:fixtures:load)。一篇文章属于一个类别(category_id),并且有一个作者(user_id)。我使用app/consoledoctrine:generate:crud为我的所有实体获取CRUD操作。当我更新一个帖子时,我得到了这个奇怪的错误:ContextErrorException:CatchableFatalError:Ob

php - Symfony2 表单集合 : How to remove entity from a collection?

我尝试从集合中删除实体,但它不起作用。我想我在某处有错误,但我不知道在哪里。这是我的updateAction中的代码:$em=$this->getDoctrine()->getEntityManager();$entity=newPerson();if(!$entity){throw$this->createNotFoundException('UnabletofindPersonentity.');}$editForm=$this->createForm(newPersonType(),$entity);$deleteForm=$this->createDeleteForm($id)

php - Symfony/学说 : Why my integer Entity attribute is returning as string?

我有一个实体,其属性定义如下:/***@varinteger**@ORM\Column(name="weight",type="integer")*/private$weight;我试图解决一个错误并使用var_dump()来了解正在发生的事情......响应是:string'20'(length=2)我不明白为什么$weight作为字符串返回...它不应该是一个整数吗?int20或者我应该在我的业务逻辑中处理它吗?编辑(我如何调用var_dump()):我有一个名为“Calculator”的类,它迭代$items并使用$weight属性。是这样的:Controller:$calcul