草庐IT

entity_store

全部标签

php - Symfony2 : How to modify the current user's entity using a form?

我正在尝试添加一个简单的表单以允许我的用户编辑他们的个人资料。我的问题是:由于“链接”到表单的实体与当前用户对象相同($user===$entity,见下文),如果表单验证失败,则View是使用修改后的用户对象呈现(即使用无效形式的值)。这是我的(经典)Controller:publicfunctionprofileAction(){$em=$this->getDoctrine()->getEntityManager();$user=$this->get('security.context')->getToken()->getUser();$entity=$em->getReposit

php - 如何避免 "Entities passed to the choice field must be managed. Maybe persist them in the entity manager?"

GeneratedEntities来自现有数据库GeneratedCRUDController但它不适用于异常消息:Entitiespassedtothechoicefieldmustbemanaged.Maybepersistthemintheentitymanager?实体/***Question**@ORM\Table(name="question",indexes={@ORM\Index(name="question_category_id",columns={"question_category_id"})})*@ORM\Entity*/classQuestion{//...

PHP/WordPress : Storing post content into variable?

当使用the_post()循环时,如何获取发布数据?我无法使用the_content()检索帖子内容数据,因为它会自动“打印”屏幕上的内容。我需要将它存储在一个值中以便我可以对其进行操作,我只需要显示标题内容的一小部分。 最佳答案 使用get_the_content()获取帖子的内容 关于PHP/WordPress:Storingpostcontentintovariable?,我们在StackOverflow上找到一个类似的问题: https://stack

PHP : imploding array and storing the result back to same variable

下面的代码有没有坑。这样使用安全吗?我不会再使用该阵列$records_msg=implode("",$records_msg); 最佳答案 不是真的,但是为数组使用不同的变量名可能会提高可读性,因为它还不是消息。 关于PHP:implodingarrayandstoringtheresultbacktosamevariable,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/33

php - 执行 html_entity_decode 后出现奇怪的字符 (�)

在一个单独的YML文件中,我有:flags:[]当我将它调用到我的代码中时,它没有被解释,所以我使用了html_entity_decode.它有效,但我只有1个奇怪的字符在我的图像之前:�render());?>我的所有文件都是UTF8编码的。你知道我错过了什么来解决这个问题吗?附言:publicstaticfunctiongetI18nCulturesForChoice(){returnarray_combine(self::getI18nCultures(),self::getI18nCulturesFlags());} 最佳答案

php - 类中的 Doctrine 注释 "@Doctrine\ORM\Annotation\Entity"不存在或无法自动加载

我正在关注DoctrineGettingStarted字母教程。我已经创建了Product类(通过从教程中复制/粘贴,以确保没有拼写错误),但是当我运行时vendor/bin/doctrineorm:schema-tool:create我得到[OK]NoMetadataClassestoprocess。这似乎是因为Setup::createAnnotationMetadataConfiguration的useSimpleAnnotationReader参数默认为true。因此,如果我将其更改为false:$config=Setup::createAnnotationMetadataCo

php - 扩展 mysqli_result - 它使用 store_result() 还是 use_result()

我用返回mysqli_result的子项的查询方法编写了一个mysqli的子项。此结果子项将具有我的应用独有的其他方法。publicMySQLextendsmysqli{publicfunctionquery($query){if($this->real_query($query)){if($this->field_count>0){returnnewMySQL_Result($this);}returntrue;}returnfalse;}}classMySQL_Resultextendsmysqli_result{publicfunctionfetch_objects(){$row

php - 学说 2 : reattaching entities through value objects

我正在使用Doctrine2,并且有一个Address值对象:classAddress{/**@varstring*/protected$street;/**@varstring*/protected$city;/**@varApplication\Domain\Model\Country*/protected$country;}我需要将此Address存储在PHPsession中(序列化),并在稍后检索它。当我随后检索这个值对象时,我想将Country对象合并到当前的实体管理器,以便这个国家与当前的工作单元同步。是否可以将这个值对象“合并”到当前的实体管理器,就像我使用cascade

php - 有什么方法可以将 Entity Framework 与 mysql 和 php 一起使用?

我想知道是否有任何方法可以将EntityFramework与mysql和php一起使用。是否需要任何连接器或特殊程序。能否请您介绍一些引用资料供我阅读? 最佳答案 EntityFramework是.NET的ORM,它不是php或类似东西的“端口”,即使在那种情况下,我怀疑它是否会比当前的PHPORM框架更好。如果你想在PHP中使用ORM,那么你有很多选择,你应该阅读一些关于备选方案的信息并选择ORM。就我个人而言,我使用Doctrine框架http://www.doctrine-project.org/

php - 如何用预言测试 Doctrine Entity Manager findOneById 方法?

我正在使用预言来编写我的单元测试"require":{...,"phpspec/prophecy-phpunit":"~1.0"},我调用$dbUser=$this->em->getRepository('MainBundle:User')->findOneById($id);测试时出现错误,因为未定义findOneByProperty方法。除了将原始代码更改为:$dbUser=$this->em->getRepository('MainBundle:User')->findOneBy(array('id'=>$id);我没有找到任何其他解决方法。有什么方法可以使用预言并保留原始代码来