我正在尝试使用Drush删除基于其标题的Drupal节点。
我正在调用的delete_poi.php
脚本如下所示:
<?php
// get the name of the POI that is entered with the Drush command
$poi_title = drush_get_option('poi');
// query the database for the node with type poi and title poi_title and delete it
$sql = db_query("SELECT nid FROM node WHERE title = '" . $poi_title . "';");
while ($node = db_fetch_object($sql)) {
node_delete($node->nid);
drush_print('deleted poi ' . $node->title);
}
我正在使用的Drush命令是:
drush scr delete_poi.php --poi='Historium'
运行脚本时,我得到以下输出(我也尝试过使用php脚本):
Drush command terminated abnormally due to an unrecoverable error.
Error: Call to undefined function db_query() in /vagrant/site/delete_poi.php, line 6
我一直在关注脚本https://coderwall.com/p/stbxbw的本教程,并一直在Drupal论坛和Stackexchange中搜索答案,但一直无法找到解决方案。
我猜测引导Drupal存在问题,因为无法识别Drupal API(如db_query)的方法。当我尝试使用drush en module_name
启用模块时,出现以下错误:
Command pm-enable needs a higher bootstrap level to run - you will need invoke drush from a more functional Drupal environment to run this command.
The drush command 'en delete_all' could not be executed.
A Drupal installation directory could not be found
你有什么想法吗?如果您需要更多信息,请告诉我。