if ($willLimitByDB) $sql = preg_replace('/#([^#]+)#/i', '$$1',
$sql);
This does not give me the results I want, instead of the value of
$where in $sql, I literally get '$where' instead.
How do I substitute #where# with $where?
Thanx
Phil 5 2252
comp.lang.php wrote: if ($willLimitByDB) $sql = preg_replace('/#([^#]+)#/i', '$$1', $sql);
This does not give me the results I want, instead of the value of $where in $sql, I literally get '$where' instead.
How do I substitute #where# with $where?
Thanx Phil
given: $sql="select * from table";
and $where="where a = 'a'";
$sql .= $where;
//concatenate it before you edit it...
if ($willLimitByDB) $sql = preg_replace('/#([^#]+)#/i', '$$1', $sql);
noone wrote: comp.lang.php wrote:
if ($willLimitByDB) $sql = preg_replace('/#([^#]+)#/i', '$$1', $sql);
This does not give me the results I want, instead of the value of $where in $sql, I literally get '$where' instead.
How do I substitute #where# with $where?
Thanx Phil
given: $sql="select * from table"; and $where="where a = 'a'";
$sql .= $where; //concatenate it before you edit it... if ($willLimitByDB) $sql = preg_replace('/#([^#]+)#/i', '$$1', $sql);
Thanx but you were looking at the wrong "WHERE.."
the query is this
"SELECT id, first_name, last_name, (SELECT count(id) #where#) as
paginate_total, email, address, city, state, zip, phone FROM person
$where "
You want "#where#" inside the subselect substituted with $where
I got it though thanx to someone that knows RegExp modifiers
$sql = preg_replace('/#([^#]+)#/ie', '$$1', $sql);
Phil
comp.lang.php wrote: "SELECT id, first_name, last_name, (SELECT count(id) #where#) as paginate_total, email, address, city, state, zip, phone FROM person $where "
You want "#where#" inside the subselect substituted with $where
So basically you are selecting "id, first_name, last_name ..." and
count of the returned results? Why not just ask the DB how many rows it
returned?
/marcin
Marcin Dobrucki wrote: comp.lang.php wrote:
"SELECT id, first_name, last_name, (SELECT count(id) #where#) as paginate_total, email, address, city, state, zip, phone FROM person $where "
You want "#where#" inside the subselect substituted with $where
So basically you are selecting "id, first_name, last_name ..." and count of the returned results? Why not just ask the DB how many rows it returned?
/marcin
Because the resultset will have, for example, only 20 rows while the
entire table might have 20,000 rows. I must show how many total
records exist, all the while, only display a unit of 20.
Phil
comp.lang.php wrote: "SELECT id, first_name, last_name, (SELECT count(id) #where#) as paginate_total, email, address, city, state, zip, phone FROM person $where "
You want "#where#" inside the subselect substituted with $where So basically you are selecting "id, first_name, last_name ..." and count of the returned results? Why not just ask the DB how many rows it returned?
Because the resultset will have, for example, only 20 rows while the entire table might have 20,000 rows. I must show how many total records exist, all the while, only display a unit of 20.
But your original post said:
"How do I substitute #where# with $where?"
So if your count-select is also governed by the same "where"
statement, then your count will be that of the selected set.
There are also simpler ways (IMHO) to get the total, eg, just run a
second separate select query with only count(id).
/m This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: nephish |
last post by:
hey there,
i have a script that retrieves my email, but i need it to
be able to strip all the stuff off except the body (the message itself)
so i...
|
by: Gary McCullough |
last post by:
What I want to do sounds simple, but it's defeating me. I want to
substitute all occurences of a colon : character in a string with an @
character...
|
by: Martijn van Oosterhout |
last post by:
I've had some fun in the past where I've had to grant a lot of tables and
other similar system commands. Unfortunatly, you can't use queries to fill...
|
by: Susan |
last post by:
Customer Orders are ranked from 1 to 10 and are assigned an order type of 1,
2 or 3. The table for this is:
TblOrderRankType
OrderRankTypeID...
|
by: Felix Kater |
last post by:
The C-faq says that "The malloc/free implementation remembers the size
of each block allocated and returned, so it is not necessary to remind
it of...
|
by: Jack Addington |
last post by:
I've got a fairly simple application implementation that over time is going
to get a lot bigger. I'm really trying to implement it in a way that...
|
by: MLH |
last post by:
Instead of DLookUp(Field, Tbl/Qry, Where clause), I was hoping
to be able to substitute an expression for the tbl/qry parm
?DLookUp("","tblAdmin...
|
by: bsruth |
last post by:
I tried for an hour to find some reference to concrete information on
why this particular inheritance implementation is a bad idea, but
couldn't. ...
|
by: aschauhan18 |
last post by:
Hi
Does Anybody help me
Substitute Of Last() Function Of Ms Acces 2000 in Sql Server 2000 .
This is my query...
|
by: teenabhardwaj |
last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
|
by: Kemmylinns12 |
last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
|
by: CD Tom |
last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
|
by: CD Tom |
last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
|
by: Matthew3360 |
last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function.
Here is my code.
...
|
by: Matthew3360 |
last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
|
by: AndyPSV |
last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
|
by: Arjunsri |
last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
|
by: WisdomUfot |
last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
| |