Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When I use the SQL construction with db_quey and db_fetch array I do not get results.
When I use the construction like in drupal.org/node/355808 the thing works
Comments
Comment #1
socratesone CreditAttribution: socratesone commentedIt looks like the database only has access to the information within the scope of the view.
I would like to be able to use database calls, as well. I'm sure that there is a module I can invoke inside the php customfield, but I'm not sure how to do this or what module to use.
Comment #2
crystaldawn CreditAttribution: crystaldawn commentedI was not able to reproduce this behavior using the development version. I put this in a phpcode field and it returned the desired result. As far as I know, variable table is not within the scope of the view.
Comment #3
MantasK CreditAttribution: MantasK commentedI'm not sure if this module is causing these sql related issues. In my local dev version I'd created a view with custom field which had quite complex sql query, but I couldn't import it to production server. My version was outdated, so maybe other modules were causing it. So after some hours of trying to figure what was wrong I've commented
in views_customfield_handler_field_phpcode.inc
and wrote $output = 'blabla';
but error still was there, so finally I've found a "bug". Not bug, but solution and it is:
'SELECT * FR' . 'OM {table}'
yes. I'm not kidding, that word "from" alone is causing whole chaos.
That was my case, maybe there are some other ones.
Comment #4
leewebdev CreditAttribution: leewebdev commentedThanks MantasK. This has been driving me crazy for hours now -- until I tried your weird solution. But it works! For the life of me I can't figure out why. Just out of curiosity I tried that to the SELECT word ("SEL" . "ECT ) instead of the FROM word and that worked too. Trying a concatenation anywhere else the normal way through the error. Anyway, thanks for posting your solution as it helped my tremendously.