Re: constants inside of a string
| From: | Toby Butzon | Date: | Wed, 10 Jan 2001 20:51:52 +0000 |
| Subject: | Re: constants inside of a string | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-33774@lists.php.net to get a copy of this message | ||
This reminded me of an issue I've kind of been contemplating
for a couple of weeks now... I got sick of having to
connect, query, check for errors, etc. every time I wanted
to query a mysql database, so I wrote a function to do all
of it for me... something like:
function query_db($queryString, $file, $line) {
// do db stuff
// if error, die using $file and $line (actually using
constants __FILE__ and __LINE__ only tell me that it died in
this function)
// return results of query
}
Now, to call the function I've been using:
$result = query_db("SELECT * FROM myTable", __FILE__,
__LINE__);
It'd be nice to be able to get __FILE__ and __LINE__ where
the function was called without passing them as parameters.
Even if I could just define a macro _HERE_ to expand into
__FILE__, __LINE__ it would save me some time...
I know it sounds lazy, but if there was a way so I could
just call
$result = query_db("SELECT * FROM myTable");
it'd be so much nicer...
PS - I don't want to get into db abstraction and all that...
I just wonder if what I'm talking about is easy/possible.
Thanks for input -
--Toby
----- Original Message -----
From: "Moritz Petersen" <lists@jface.de>
Sent: Wednesday, January 10, 2001 3:18 PM
Subject: RE: [PHP] constants inside of a string
<snip>