473,404 Members | 2,174 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

OVERRIDING functions

I want that every time the built-in 'mysql_query' function is called another user function is also called.
But i can't call the user function explicitly, I can only call the built-in function.

Any idea?

Much thx in advance.
Jul 17 '05 #1
5 8037
<so*****@somedomain.com.invalid> wrote:
I want that every time the built-in 'mysql_query' function is called another user function is also called.
But i can't call the user function explicitly, I can only call the built-in function.

Any idea?


You mean apart from changing the PHP source and recompiling?
No, no idea.
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #2
Pedro Graca wrote:
<so*****@somedomain.com.invalid> wrote:
I want that every time the built-in 'mysql_query' function is called another user function is also called.
But i can't call the user function explicitly, I can only call the built-in function.

Any idea?

You mean apart from changing the PHP source and recompiling?
No, no idea.


Do the two functions have the same name?

Jul 17 '05 #3
paul brown wrote:
Pedro Graca wrote:
<so*****@somedomain.com.invalid> wrote:
I want that every time the built-in 'mysql_query' function is called another user function is also called.
But i can't call the user function explicitly, I can only call the built-in function.

Any idea?
You mean apart from changing the PHP source and recompiling?
No, no idea.
Do the two functions have the same name?


What two functions?
Get the PHP source: http://www.php.net/downloads.php

Edit "php-src/ext/mysql/php_mysql.c".
Compile.
Voila!
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #4
> What two functions?

I'm guessing he's referring to both the built-in function and the user one.
Jul 17 '05 #5
This is kinda clunky, but what you can do is dynamically rewrite the code,
replacing calls to mysql_query with mysql_query_user.

Add this snippet to the beginning of your code:

if(!$eval) {
function mysql_query_user() {
$args = func_get_args();
print_r($args);
call_user_func_array('mysql_query', $args);
}

$eval = true;
$code = file_get_contents($_SERVER['SCRIPT_FILENAME']);
$code = preg_replace('/(?<=\\s)mysql_query\\s*\\(/', 'mysql_query_custom(',
$code);
eval("?>$code");
exit();
}

This won't work, of course, if the call to mysql_query is buried in an
included file.

Uzytkownik <so*****@somedomain.com.invalid> napisal w wiadomosci
news:bt**********@nsnmrro2-gest.nuria.telefonica-data.net...
I want that every time the built-in 'mysql_query' function is called another user function is also called. But i can't call the user function explicitly, I can only call the built-in function.
Any idea?

Much thx in advance.

Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: James Marshall | last post by:
I'm writing a library where I want to override document.write(), but for all document objects; thus, I want to put it in the prototype. I tried Document.prototype.write= my_doc_write ; but it...
8
by: Edward Diener | last post by:
Is it possible for a derived class to override a property and/or event of its base class ?
5
by: Hongzheng Wang | last post by:
Hi, I have a problem about the overriding of private methods of base class. That is, if a method f() of base class is private, can the derived class overriding f() be overriding? For...
1
by: Xiangliang Meng | last post by:
Hi, all. When reading C++ books, I'm alway confused by those terms "redefining functions", "overloading functions" and "overriding functions". Please give me some comments on those terms....
2
by: franklini | last post by:
hello people i. can anybody help me, i dont know what is wrong with this class. it has something to do with the me trying to override the input output stream. if i dont override it, it works fine....
11
by: iceColdFire | last post by:
Hi, What is the Diff btwn Function overloading and overriding thanks, a.a.cpp
15
by: Susan Baker | last post by:
Hello everybody, I'm new to C++ (I have some C background). I've read up on this topic a few times but it just dosen't seem to be sinking in. 1. Whats the difference between overloading and...
3
by: David Scarlett | last post by:
Hi all, I've got a question regarding overriding const member functions with non-const functions. Let's say I've got a base class defined as follows: /*******************/ class Foo {...
7
by: Lighter | last post by:
Is overriding a function of a library in accordance with C++ standard? The following code are passed by the VS 2005 and Dev C++. #include <cstdlib> #include <iostream> using namespace std;...
8
by: yashwant pinge | last post by:
#include<iostream> using namespace std; class base { public: void display() { } };
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.