Log in

View Full Version : Hook to replace


ericgtr
03-11-2006, 01:32 PM
I am not sure if this is possible but I would like to use the hook system if I can for this.

In attachment.php I have this code:

// or doing it once an hour
$query = "INSERT INTO " . TABLE_PREFIX . "attachmentviews (attachmentid)
VALUES ($attachmentinfo[attachmentid])
";
defined('NOSHUTDOWNFUNC') ? $db->query_write($query) : $db->shutdown_query($query);
}


I would like to replace it with this:

// or doing it once an hour
$query = "INSERT INTO " . TABLE_PREFIX . "attachmentviews (attachmentid, timestamp)
VALUES ($attachmentinfo[attachmentid], " . TIMENOW . ")
";
defined('NOSHUTDOWNFUNC') ? $db->query_write($query) : $db->shutdown_query($query);
}


It would be nice if I didn't have to force the user to edit the file for this mod :)

Trigunflame
03-11-2006, 01:46 PM
I am not sure if this is possible but I would like to use the hook system if I can for this.

In attachment.php I have this code:

// or doing it once an hour
$query = "INSERT INTO " . TABLE_PREFIX . "attachmentviews (attachmentid)
VALUES ($attachmentinfo[attachmentid])
";
defined('NOSHUTDOWNFUNC') ? $db->query_write($query) : $db->shutdown_query($query);
}


I would like to replace it with this:

// or doing it once an hour
$query = "INSERT INTO " . TABLE_PREFIX . "attachmentviews (attachmentid, timestamp)
VALUES ($attachmentinfo[attachmentid], " . TIMENOW . ")
";
defined('NOSHUTDOWNFUNC') ? $db->query_write($query) : $db->shutdown_query($query);
}


It would be nice if I didn't have to force the user to edit the file for this mod :)

The query is being executed directly after it is assigned; the only way you theoretically could modify it is if a hook was placed directly after the $query = "whatever"; and then have your own $query = 'whatever'; that would overwrite it.

But looking at that, there is no way to do it through a plugin for replacing the sql in that query.

ericgtr
03-12-2006, 12:27 AM
That's pretty much what I figured, thanks for confirming.