php - symfony2序列化数据替换错误

标签 php mysql symfony serialization replace

所以我试图将实时安装移动到我的本地主机上。我的用户数据中有大量图像,这些图像已上传并插入到帖子中。

问题是实时服务器上的图像路由是

/uploads/images/...

在本地主机环境中它将是

/mysite/web/uploads/images/...

因此,我使用此处找到的 searchreplacedb2.php 脚本进行了尝试(https://interconnectit.com/products/search-and-replace-for-wordpress-databases/ 我使用 v2.1.0 稳定版),它是推荐用于移动 WordPress 安装的脚本,我认为 mySql 中的数据序列化应该在 WP 上的工作方式与在 Sym2 应用程序中的工作方式相同。

但也许不是,因为当 Sym2 尝试读取我进行搜索/替换的表时,我收到以下错误:

ContextErrorException: Notice: unserialize(): Error at offset 1672 of 1953 bytes in /Users/acr/Documents/www/cloudsign/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/ArrayType.php line 48

这是我执行替换的序列化数据的示例:

a:6:{i:0;s:11:"transparent";i:3;s:6:"repeat";i:4;s:4:"left";i:5;s:3:"top";i:6;s:1707:"<div id="object_01" class="object_image lockedAspectRatio ui-draggable ui-resizable" namn="object_01" style="height:1036.5599999427795px;width:1635.5599999427795px;left:-1.994384765625px;top:-15px;position:absolute;"><img class="object_inner" src="/cloudsign/web/uploads/images/20/c274edd7f10f5d34157108658d9e7e6eebf16bb4.jpeg" alt="c274edd7f10f5d34157108658d9e7e6eebf16bb4" /><div class="ui-resizable-handle ui-resizable-e" style="z-index:1000;"></div><div class="ui-resizable-handle ui-resizable-s" style="z-index:1000;"></div><div class="ui-resizable-handle ui-resizable-se ui-icon ui-icon-gripsmall-diagonal-se" style="z-index:1000;"></div></div><div id="object_02" class="object_textbox" namn="object_02" style="z-index:2;font-family:Arial;left:940.9950561523438px;top:84.98873901367188px;position:absolute;width:493.55999994277954px;height:77.55999994277954px;"><div class="object_inner" style="border:0px solid rgb(0,0,0);background-color:rgb(163,178,240);color:rgb(255,255,255);font-weight:bold;font-family:Arial;font-size:44px;line-height:66px;text-align:center;">Vinter Kampanj!</div></div><div id="object_03" class="object_textbox" namn="object_03" style="z-index:3;font-family:Arial;left:917px;top:215px;position:absolute;width:549.5599999427795px;height:625.5599999427795px;"><div class="object_inner" style="border:0px solid rgb(0,0,0);color:rgb(0,0,0);text-align:center;font-weight:bold;font-size:44px;line-height:66px;border-top-left-radius:15px;border-top-right-radius:15px;border-bottom-right-radius:15px;border-bottom-left-radius:15px;">Missa inte vår stora vinter rea med upp till 70% rabatt! <br /><br /><br />Många stora märken som North Face, Peak<br />Adidas, Columbia, Burton m.m.</div></div>";i:7;s:8:"original";}

最佳答案

您可以在开发过程中使用 Doctrine Lifecycle 回调来更改该路径,而不是更改数据库内容。我的观点是,您可以使用 @PostLoad 以更优雅的方式实现您想要的。

引用:Doctrine Lifecycle Callbacks

关于php - symfony2序列化数据替换错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26505790/

相关文章:

mysql - 导入schema.sql时出错

Symfony2 : Best practice for access control

symfony - Composer 找不到我安装的包

php - 在 cakephp 中使用回调方法解密和加密

php - 使用 PHP 和 Curl 将 Google AdWords API 用于关键字工具?

PHP MySQL 连接关闭

php - 限制 mysql 查询的多个结果

php - 所有 API 路由的语言和国家

php - 如何在PHP中使用简单的点赞页面多次点赞?

php - 将文件上传到 mySQL 数据库。帮助代码