note 87295 modified in function.override-function by danbrown

From: Date: Fri, 28 Nov 2008 16:33:01 +0000
Subject: note 87295 modified in function.override-function by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-147073@lists.php.net to get a copy of this message
I had the same problem and, since the __overriden__() name is hardcoded, I simply ended up renaming that one. I use it like this: <?php function _dbslayer_map() { $substs = array( 'mysql_connect' => 'dbslayer_mysql_connect($host, $user, $pass, $new_link, $client_flags)', 'mysql_fetch_array' => 'dbslayer_mysql_fetch_array($result, $result_type)', 'mysql_query' => 'dbslayer_mysql_query($query, $link_identifier)' ); $args = array( 'mysql_connect' => '$host = NULL, $user = NULL, $pass = NULL, $new_link = false, $client_flags = 0', 'mysql_fetch_array' => '&$result, $result_type = MYSQL_BOTH', 'mysql_query' => '$query, $link_identifier = DEFAULT_LINK' ); foreach ($substs as $func => $ren_func) { override_function($func, $args[$func], "return $substs[$func];"); rename_function("__overridden__", $ren_func); } } ?> So far, so good. --was-- I had the same problem and, since the __overriden__() name is hardcoded, I simply ended up renaming that one. I use it like this: function _dbslayer_map() { $substs = array( 'mysql_connect' => 'dbslayer_mysql_connect($host, $user, $pass, $new_link, $client_flags)', 'mysql_fetch_array' => 'dbslayer_mysql_fetch_array($result, $result_type)', 'mysql_query' => 'dbslayer_mysql_query($query, $link_identifier)' ); $args = array( 'mysql_connect' => '$host = NULL, $user = NULL, $pass = NULL, $new_link = false, $client_flags = 0', 'mysql_fetch_array' => '&$result, $result_type = MYSQL_BOTH', 'mysql_query' => '$query, $link_identifier = DEFAULT_LINK' ); foreach ($substs as $func => $ren_func) { override_function($func, $args[$func], "return $substs[$func];"); rename_function("__overridden__", $ren_func); } } So far, so good. http://php.net/manual/en/function.override-function.php

« previous php.notes (#147073) next »