PDA

View Full Version : Using str_replace() to modify query, is it possible?


Antivirus
08-03-2007, 07:35 PM
In newattachment.php i want to modify the following query:

SELECT dateline, filename, filesize, attachmentid, IF(thumbnail_filesize > 0, 1, 0) AS hasthumbnail
FROM " . TABLE_PREFIX . "attachment
WHERE postid = $postid
ORDER BY attachmentid


so it becomes this:

SELECT dateline, filename, filesize, attachmentid, IF(thumbnail_filesize > 0, 1, 0) AS hasthumbnail
FROM " . TABLE_PREFIX . "attachment
WHERE scst_usedin = 'fbid' AND scst_itemid = '" . $feedback['fbid'] . "'
ORDER BY attachmentid


The problem is that there's no hook in newattachment.php which allows me to alter the query, so I'm thinking it's possible to place a plugin at hook: GLOBAL_START like this:


if (THIS_SCRIPT == 'newattachment' AND $_REQUEST['type'] == 'fb')
{
str_replace(
' WHERE postid = $postid ',
' WHERE scst_usedin = \'fbid\' AND scst_itemid = \'\" . $feedback['fbid'] . \"\' ',
$currentattaches2
);
}


I know this won't work, but is there some similar function in PHP which tells the engine "when you get to a certain string of code, use one thing instead of what was originally there"?

thanks!

Antivirus
08-10-2007, 10:57 AM
bump, anyone please?

Marco van Herwaarden
08-10-2007, 11:09 AM
I would not know of a way to do that.

(other then acutally editing the php-file.)

Antivirus
08-10-2007, 12:59 PM
damn, it looks like that's the way I might have to go. I was really hoping to avoid that though. If anyone does know of a way, still, please let me know.