如何在SQLite中重命名索引?(How to rename an index in SQLite?)
在MySQL等其他数据库中,我可以这样做:
ALTER TABLE demo RENAME INDEX old_index TO new_index
什么是SQLite最好的解决方法?
更新
SQLite似乎不支持这种语法。 在哪种情况下我可以使用的工作。 例如:
DROP INDEX old_index; CREATE INDEX new_index ON demo(col1, col2);
上面的问题是我需要手动找出索引的列。 我想要一些可以自动完成的事情,如:
set columns = select columns indexed by old_index; DROP INDEX old_index; CREATE INDEX new_index ON demo(columns);
In other databases such as MySQL I could just do this:
ALTER TABLE demo RENAME INDEX old_index TO new_index
What's the best workaround for SQLite?
Update
SQLite does not seem to support this syntax. In which case is there a work around I can use. For example:
DROP INDEX old_index; CREATE INDEX new_index ON demo(col1, col2);
The issue with the above is that I need to manually find out which columns were indexed. I want something that can be done automatically like:
set columns = select columns indexed by old_index; DROP INDEX old_index; CREATE INDEX new_index ON demo(columns);
原文:
最满意答案
菜单不完整,你只是没有正确检查代码。
以下代码将加载菜单的数组。 该数组包含构建菜单所需的全部信息。 然后,您可以递归地循环访问数组,以使用您需要的HTML结构来构建菜单。 如果您将此菜单添加到现有菜单中,这很有用,因为它允许您匹配现有菜单使用的HTML结构。
// This uses the object manager // A better way would be to inject the MenuFactory in your constructor $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $menu = $objectManager->create('FishPig\WordPress\Model\MenuFactory')->create(); $menuId = 3; if ($menu->load($menuId)->getId()) { echo sprintf('<pre>%s</pre>', print_r($menu->getMenuTreeArray(), true)); } else { echo 'No menu exists in WordPress with an ID of ' . (int)$menuId; }
如果您不关心使用哪种HTML结构,则可以使用以下块:
\FishPig\WordPress\Block\Sidebar\Widget\NavMenu
如果您查看该块的代码,您会看到它检查数据项“nav_menu”以获取菜单ID。 你可以通过XML来设置它(如果你通过XML创建块)或者使用PHP创建整个事物:
$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $menuBlock = $objectManager->create('FishPig\WordPress\Block\Sidebar\Widget\NavMenuFactory')->create(); $menuId = 3; echo $menuBlock->setNavMenu($menuId)->toHtml();
这个解决方案不如原来的解决方案好,因为它迫使你使用特定的HTML结构。 使用第一种解决方案会更好,因为这可以让您使用任何您需要的HTML结构。 你的主题可能已经有一个CSS规则和JS的菜单,所以你可以使用这个方法在正确的HTML结构中建立菜单。
Menu's are not incomplete, you just haven't checked the code properly.
The following code will load an array of the menu. This array contains all of the information you need to build the menu. You can then recursively loop through the array to build the menu using the HTML structure that you require. This is useful if you are adding this menu to an existing menu as it allows you to match the HTML structure used by your existing menu.
// This uses the object manager // A better way would be to inject the MenuFactory in your constructor $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $menu = $objectManager->create('FishPig\WordPress\Model\MenuFactory')->create(); $menuId = 3; if ($menu->load($menuId)->getId()) { echo sprintf('<pre>%s</pre>', print_r($menu->getMenuTreeArray(), true)); } else { echo 'No menu exists in WordPress with an ID of ' . (int)$menuId; }
If you don't care what HTML structure is used, you can use the following block:
\FishPig\WordPress\Block\Sidebar\Widget\NavMenu
If you look through the code of this block, you will see it checks the data item 'nav_menu' for the menu ID. You can set this via XML (if you created the block via XML) or create the whole thing using PHP:
$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $menuBlock = $objectManager->create('FishPig\WordPress\Block\Sidebar\Widget\NavMenuFactory')->create(); $menuId = 3; echo $menuBlock->setNavMenu($menuId)->toHtml();
This solution isn't as good as the original solution though as it forces you to use a specific HTML structure. You would be much better using the first solution, as this will allow you to use any HTML structure that you require. Your theme probably already has a menu with CSS rules and JS in place so you could use this method to build the menu in the correct HTML structure.
相关问答
更多-
Fishpig Magento和qTranslate整合。(Fishpig Magento and qTranslate integration. (hooks and filters))[2022-03-26]
Axel是正确的,因为扩展直接连接到WordPress数据库,并通过Magento模型,块,控制器等提取数据和显示。因此,需要额外的Magento扩展,增加对qTranslate WordPress插件的支持。 完成由Magento中WordPress控制的多语言博客的另一种方法如下: 在Magento站点的子目录中设置一个名为“wp”的WordPress多站点安装。 为您的每种语言创建不同的博客。 使用Magento WordPress多站点集成,您可以将这些博客中的每一个与相应的Magento商店视图相 ... -
在Wordpress / Magento PHP循环中每3个帖子添加一个图像(Add an image every 3 posts in Wordpress/Magento PHP loop)[2024-04-15]
这很简单。 只需使用以下代码: getPosts() ?> 0): ?>-
在magento不工作的fishpig wordpress集成 - 致命错误(fishpig wordpress integration in magento not working - Fatal error)[2022-09-15]
这是通过升级到最新版本(撰写本文时为3.0.0.16)来解决的。 This was fixed by upgrading to the latest version (3.0.0.16 at the time of writing). -
Fishpig Wordpress Magento集成 - 获取所有作者的列表(Fishpig Wordpress Magento integration - get the list of all authors)[2021-08-26]
您可以使用以下代码检索作者集合: 然后,您可以按如下方式列出: 0): ?>您还需要在WordPress Admin中安装免费的Disqus插件,设置Disqus帐户并配置所有内容。 一旦在Disqus和WordPress管理员中配置了这个,FishPig扩展程序将读取此数据并自动显示Disqus评论。 You will also need to install the free Disqus plugin in your WordPress Admin, setup a Disqus account and configure everything. Once this has ...您需要将扩展升级到最新版本,因为此错误现在已修复。 You need to upgrade the extension to the latest version as this bug has now been fixed.我解决了这个问题: 创建Magento“订阅”控制器 - 我将app/code/community/Fishpig/Wordpress复制到app/code/local/Fishpig/Wordpress/并创建app/code/local/Fishpig/Wordpress/controllers/SubscribeController.php 在SubscribeController.php创建subscribeAction()方法。 subscribeAction()方法使用makeHttpPostR ...要删除所需的条目,请转到fishpig模块中的system.xml,删除节点内的 required-entry 。 这样您就可以使用空密码保存。 To remove required entry, go to system.xml inside fishpig module, removerequired-entry insidenode. This way ... 菜单不完整,你只是没有正确检查代码。 以下代码将加载菜单的数组。 该数组包含构建菜单所需的全部信息。 然后,您可以递归地循环访问数组,以使用您需要的HTML结构来构建菜单。 如果您将此菜单添加到现有菜单中,这很有用,因为它允许您匹配现有菜单使用的HTML结构。 // This uses the object manager // A better way would be to inject the MenuFactory in your constructor $objectManager = \Mage ...如果你想在Magento中使用各种Wordpress插件,如上所述,简短的答案是否定的。 使用您提供的链接,您可以实现以下目标: 使用wordpress插件(您提供的链接),您可以拥有yourwordpress.com,然后在文件夹中安装Magento,以便Magento商店可用。 例如,在yourwordpress.com/magentostore/中,您可以轻松地在Wordpress网站中显示商店中的任何Magento块(顶部链接,类别,分层导航块等)。 使用Magento插件(我将使用FishPig ...相关文章
更多- Python 在Linux中使用SQLite3
- sqlite怎么做多表关联。。。
- 为什么不能我的sqlite不能创建主外键关联。。。
- 用SQLite查看编辑android导出的微信聊天记录
- 顶 lucene--创建index
- 利用SolrJ操作solr API完成index操作
- Solr4.7.2启动时的Index locked for write for core问题分析
- Solr4.8.0源码分析(3)之index的线程池管理
- Hibernate Search(基于version3.4)--第四章Mapping entities to the index structure
- [Hadoop 2.2 + Solr 4.5]系列之三:MapReduce + Lucene 生成Index文件
最新问答
更多- 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
- 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
- OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
- 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
- codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
- 在计算机拍照在哪里进入
- 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
- No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
- 单页应用程序:页面重新加载(Single Page Application: page reload)
- 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
- System.StackOverflow错误(System.StackOverflow error)
- KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
- 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
- android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
- TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
- 企业安全培训的各项内容
- 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
- C#类名中允许哪些字符?(What characters are allowed in C# class name?)
- NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
- 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
- 将多个行和可变行移动到列(moving multiple and variable rows to columns)
- 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
- 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
- Angular $资源不会改变方法(Angular $resource doesn't change method)
- 在Angular 5中不是一个函数(is not a function in Angular 5)
- 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
- 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
- 常见的python rpc和cli接口(Common python rpc and cli interface)
- Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
- 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)
-