Call to undefined function db_result
// this errors - db_result
$count = db_result(db_query("SELECT COUNT(*) FROM {node} WHERE type = '%s'", $type));
// suggestion
$count = db_select('node')->condition('type', $type)->countQuery()->execute()->fetchField();
Fatal error: Call to undefined function _content_tablename() in /sites/all/modules/delete_all/delete_all.module on line 268
_content_tablename($type, CONTENT_DB_STORAGE_PER_CONTENT_TYPE)
Is this something from D6 or a missing module?
Thanks!
| Comment | File | Size | Author |
|---|---|---|---|
| #25 | interdiff-21-25.txt | 16.93 KB | hkirsman |
| #25 | delete_all-call_to_undefined_function_db_result-1580428-25.patch | 19.08 KB | hkirsman |
| #21 | delete_all-call_to_undefined_function_db_result-1580428-21.patch | 5.71 KB | hkirsman |
| #18 | delete_all_working_D7-v3.patch | 722.72 KB | arne_hortell |
| #16 | delete_all_working_D7 (1).patch | 722.43 KB | arne_hortell |
Comments
Comment #1
hey_germanoI ran into the same thing, and this fix worked for me. db_result() is from D6 and not a part of D7.
Here's a patch of the change js suggested above.
Comment #2
coderintherye commentedOk, well I made the one liner change and committed it into dev. Thank you to both..
However, the specified error is coming from the call to _content_tablename in the quick delete function.
I think it needs a fairly complex replacement with something like http://api.drupal.org/api/drupal/modules%21field%21field.crud.inc/functi...
If anyone wants to tackle it, I'll gladly accept patches.
Comment #3
funkeyrandy commentedis there any update here? i need to delete >100k nodes daily, and need fast way of doing it (<3h)
even with the above patches, quick delete does not work
thanks!
Comment #4
indydas commentedStill broken in 7x1.1 so it seems?
Fatal error: Call to undefined function db_result() delete_all.module on line 295.
Comment #5
elijah lynn@indydas and anyone else with this error. The commit was http://cgit.drupalcode.org/delete_all/commit/?h=7.x-1.x&id=cea4afcd3c617... and was made after 7.x-1.1 and will be in 7.x-1.2. That being said, I applied the patch and am now getting a:
Notice: Undefined variable: type in delete_all_content_confirm_submit() (line 228 of /home/elijah/websites/example.com/docroot/profiles/publisher/modules/contrib/delete_all/delete_all.module).http://cgit.drupalcode.org/delete_all/log/?h=7.x-1.x
Comment #6
elijah lynnI also just downloaded 7.x-1.x-dev and it doesn't work either, same message as above. Definitely needs some love!
Comment #7
elijah lynnWhile we are at it we should add Drush support for the 'quick' command too, I don't see it right now.
Comment #8
travisc commentedThis module is currently broken for Drupal7. I suggest using VBO if you need to delete a large number of nodes at this time.
Comment #9
tezalsec commentedWould have liked some sort of message not to use the quick method on the project page for drupal 7.
Now it just looks like it's all fine and running. While the _content_tablename function isn't working for all 7 versions.
Spend 2 hours working with this module before I stumbled upon this page..
Thanks.
Comment #11
arne_hortell commenteddelete-all.module, Row 307, still have the problem with _content_tablename
$tables[_content_tablename($type, CONTENT_DB_STORAGE_PER_CONTENT_TYPE)] = $nid_vid;
Comment #12
oxydog commentedGuys, I really need this feature to delete +- 7m nodes from a live web site. This was reported 4 years ago, surely someone must have a solution by now? After all, the project does state that it is "Actively Maintained"!
Comment #13
arne_hortell commentedAs per question above, yes the _content_tablename is a D6 function.
This module seems no longer maintained.
I have tried everything with vbo and bulkdelete and others and its simply not realistic to delete LOTS of nodes.
Someone need to fix this issue in drupal.
Comment #14
arne_hortell commentedHere is the patch that finally solves this issue.
Comment #15
arne_hortell commentedQuick info
Comment #16
arne_hortell commentedSorry, this one is better.
Comment #17
arne_hortell commentedComment #18
arne_hortell commentedAlways something...
Now it should be drupal compliant but still faster than normal.
Comment #19
socialnicheguru commentedthe last patch is a database dump.
Comment #20
hkirsman commentedIndeed, the last patch contains lots of other info including database dump @arne_hortell
Comment #21
hkirsman commentedCleaned up the code from last patch
Comment #22
jeremib commented@hkirsman that latest patch isn't working for me. Possible for you to just upload your full php file for drop in replacement?
Thanks!
Comment #23
hkirsman commentedShould work. Just did:
Comment #24
ñull commentedI followed #23 instructions to test the last patch. I choose to delete the seventy somthing node of one content type, but after clicking the button "Delete all content now" on the confirmation page "Are you sure you wish to delete content?" it does seem to be very quick at all. In fact I don't have the patience to wait that long for a response from a mysql query that only deletes a few nodes. Without response it is hard to tell what is wrong.
Comment #25
hkirsman commentedI tested roughly that it takes 10 seconds to delete 1000 nodes with the quick mode and 15 seconds to delete 1000 nodes with the normal mode. Actually I'm not quite sure if the quick is that quick at all, at least with PHP 7.2.
@ñull, I noticed there is this in the code:
Could you disable that and try again? Other than that, I don't see why it could be so slow.
I went little-bit crazy with this. I would go even further but the scope of this issue is quite small. I fixed as much as I could, made UI more clearer.