我有一个 wordpress 网站和一个安装了演示数据的模板。当我在 phpmyadmin 中打开一些字段时,即使我没有进行任何更改并选择其他字段,它也会更新该字段。没问题,它什么也没更新,因为我做了零更改。然后发生的事情是 wordpress 网站的前端出现问题,因为我正在检查的领域发生了一些变化。有问题的字段中有大量的 HTML 代码,而且很多;和其中的 "字符...
我认为当我打开并关闭该字段时,更新命令会解析该字段中的内容,它看到的是 ;和“到处都是......我可能是错的。无论如何,当我查看数据并通过mysql shell查询或phpmyadmin复制它,并像以前一样将它完全更新回数据库时,有些东西正在改变,但即使使用 Notepad++ 比较插件并尽我所能查看数据,也没有任何变化......
这有意义吗?快把我逼疯了!
这是一个使用火箭主题的 wordpress 网站,带有龙门框架,以防万一有人熟悉...
这里是这个问题的视频演示
https://www.youtube.com/watch?v=ljXTDKKmUUw
好吧,答案似乎是,如果数据以序列化方式存储在字段内的数组中,则必须先用 php 反序列化才能读取,然后再用 php 进行序列化才能写入。
显然,这是 wordpress 的一个常见问题,当人们尝试进行更改 url 长度的数据库迁移时,这会导致很多挫败感。
我在这里学到了更多关于这个问题的知识: http://wpgarage.com/tips/data-portability-and-data-serialization-in-wordpress/
最佳答案
问题是有问题的数据库条目不只是包含“带有一堆冒号的文本”,这是 PHP serialized数据。没错,它是文本,但它必须被视为某种二进制。当您对序列化数据进行任意更改时,例如将单词更改为更长或更短的单词,就会破坏数据结构。当相关代码之后尝试反序列化数据时,它会失败。道德:不要随意编辑序列化数据,否则你会破坏东西。
引用自 PHP documentation : 序列化的字符串甚至不应该存储在 TEXT 字段中。
Note that this is a binary string which may include null bytes, and needs to be stored and handled as such. For example, serialize() output should generally be stored in a BLOB field in a database, rather than a CHAR or TEXT field.
无论如何,如果您遵守序列化值的规则或调整相应的结构信息,则有一些方法可以编辑 PHP 序列化数据。
甚至还有一些专门的editors或在线tools为此(我没有测试过它们)。
要了解有关序列化数据结构的更多信息,请查看链接 function documentation 中 egingell 的顶部评论在 php.net 上,它描述了 serialize()'ed 值的剖析:
String -> s:size:value;
Integer -> i:value;
Boolean -> b:value; (does not store "true" or "false", does store '1' or '0')
Null -> N;
Array -> a:size:{key definition;value definition;(repeated per element)}
Object -> O:strlen(object name):object name:object size:{s:strlen(property name):property name:property definition;(repeated per property)}
String values are always in double quotes
Array keys are always integers or strings
"null => 'value'" equates to 's:0:"";s:5:"value";',
"true => 'value'" equates to 'i:1;s:5:"value";',
"false => 'value'" equates to 'i:0;s:5:"value";',
"array(whatever the contents) => 'value'" equates to an "illegal offset type" warning because you can't use an array as a key;
however, if you use a variable containing an array as a key, it will equate to 's:5:"Array";s:5:"value";', and attempting to use an object as a key will result in the same behavior as using an array will.
关于php - 当我在 phpmyadmin 中打开一个字段时,mySQL 数据库发生了变化,但我没有做任何改变,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20330924/
我正在寻找执行以下操作的正确语法(在Perl、Shell或Ruby中):#variabletoaccessthedatalinesappendedasafileEND_OF_SCRIPT_MARKERrawdatastartshereanditcontinues. 最佳答案 Perl用__DATA__做这个:#!/usr/bin/perlusestrict;usewarnings;while(){print;}__DATA__Texttoprintgoeshere 关于ruby-如何将脚
我主要使用Ruby来执行此操作,但到目前为止我的攻击计划如下:使用gemsrdf、rdf-rdfa和rdf-microdata或mida来解析给定任何URI的数据。我认为最好映射到像schema.org这样的统一模式,例如使用这个yaml文件,它试图描述数据词汇表和opengraph到schema.org之间的转换:#SchemaXtoschema.orgconversion#data-vocabularyDV:name:namestreet-address:streetAddressregion:addressRegionlocality:addressLocalityphoto:i
我好像记得Lua有类似Ruby的method_missing的东西。还是我记错了? 最佳答案 表的metatable的__index和__newindex可以用于与Ruby的method_missing相同的效果。 关于ruby-难道Lua没有和Ruby的method_missing相媲美的东西吗?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/7732154/
我有一个奇怪的问题:我在rvm上安装了rubyonrails。一切正常,我可以创建项目。但是在我输入“railsnew”时重新启动后,我有“程序'rails'当前未安装。”。SystemUbuntu12.04ruby-v"1.9.3p194"gemlistactionmailer(3.2.5)actionpack(3.2.5)activemodel(3.2.5)activerecord(3.2.5)activeresource(3.2.5)activesupport(3.2.5)arel(3.0.2)builder(3.0.0)bundler(1.1.4)coffee-rails(
我想在一个没有Sass引擎的类中使用Sass颜色函数。我已经在项目中使用了sassgem,所以我认为搭载会像以下一样简单:classRectangleincludeSass::Script::FunctionsdefcolorSass::Script::Color.new([0x82,0x39,0x06])enddefrender#hamlengineexecutedwithcontextofself#sothatwithintemlateicouldcall#%stop{offset:'0%',stop:{color:lighten(color)}}endend更新:参见上面的#re
我试图在索引页中创建一个超链接,但它没有显示,也没有给出任何错误。这是我的index.html.erb代码。ListingarticlesTitleTextssss我检查了我的路线,我认为它们也没有问题。PrefixVerbURIPatternController#Actionwelcome_indexGET/welcome/index(.:format)welcome#indexarticlesGET/articles(.:format)articles#indexPOST/articles(.:format)articles#createnew_articleGET/article
有时我需要处理键/值数据。我不喜欢使用数组,因为它们在大小上没有限制(很容易不小心添加超过2个项目,而且您最终需要稍后验证大小)。此外,0和1的索引变成了魔数(MagicNumber),并且在传达含义方面做得很差(“当我说0时,我的意思是head...”)。散列也不合适,因为可能会不小心添加额外的条目。我写了下面的类来解决这个问题:classPairattr_accessor:head,:taildefinitialize(h,t)@head,@tail=h,tendend它工作得很好并且解决了问题,但我很想知道:Ruby标准库是否已经带有这样一个类? 最佳
我正在处理旧代码的一部分。beforedoallow_any_instance_of(SportRateManager).toreceive(:create).and_return(true)endRubocop错误如下:Avoidstubbingusing'allow_any_instance_of'我读到了RuboCop::RSpec:AnyInstance我试着像下面那样改变它。由此beforedoallow_any_instance_of(SportRateManager).toreceive(:create).and_return(true)end对此:let(:sport_
大家好!我想知道Ruby中未使用语法ClassName.method_name调用的方法是如何工作的。我头脑中的一些是puts、print、gets、chomp。可以在不使用点运算符的情况下调用这些方法。为什么是这样?他们来自哪里?我怎样才能看到这些方法的完整列表? 最佳答案 Kernel中的所有方法都可用于Object类的所有对象或从Object派生的任何类。您可以使用Kernel.instance_methods列出它们。 关于没有类的Ruby方法?,我们在StackOverflow
我真的为这个而疯狂。我一直在搜索答案并尝试我找到的所有内容,包括相关问题和stackoverflow上的答案,但仍然无法正常工作。我正在使用嵌套资源,但无法使表单正常工作。我总是遇到错误,例如没有路线匹配[PUT]"/galleries/1/photos"表格在这里:/galleries/1/photos/1/edit路线.rbresources:galleriesdoresources:photosendresources:galleriesresources:photos照片Controller.rbdefnew@gallery=Gallery.find(params[:galle