hello.i`m newbie in php and i need to boost performance of searching in database.I don`t know is it the mssql problem or php script for accsesing database.So i`m looking for help here.Here is the code that i suspect it is bad and slowing the performance and rising the time to select database rows.
[PHP]function db_get_pac_where($W_id,$surname,$name,$group,$code ,$gim_data) {
$connection=db_connect();
$q=" select * from COMMIS where (1=1) ";
$qq=array();
if (isset($W_id)&&trim($W_id)!='') {
$qq[]="(COMMIS.COMMISNO like '%$W_id%') ";
}
if (isset($name)&&trim($name)!='') {
$qq[]="(COMMIS.C1 like '%$name%') ";
}
if (isset($surname)&&trim($surname)!='') {
$qq[]="(COMMIS.C2 like '%$surname%')";
}
if (isset($gim_data)&&trim($gim_data)!='' ) {
$ymd=split("[^0-9]",$gim_data);
$qqd=array();
if (isset($ymd[0])) {
$qqd[]="YEAR(COMMIS.CDATE3)=".$ymd[0]."";
}
if (isset($ymd[1])) {
$qqd[]="MONTH(COMMIS.CDATE3)=".$ymd[1]."";
}
if (isset($ymd[2])) {
$qqd[]="DAY(COMMIS.CDATE3)=".$ymd[2]."";
}
$qq[]="(".join(" and ",$qqd).")";
}
if (sizeof($qq)>0) {
$q.=" and (".join(" and ",$qq).") ";
}
if (isset($group)&&trim($group)!=''&&trim($group)!='' ) {
$q.=" and (COMMIS.C27='$group') ";
}
if (isset($code)&&trim($code)!=''&&trim($code)!='') {
$q.=" and (COMMIS.C30 like '%$code%') ";
}
$q.=" ORDER BY COMMISNO DESC";
//echo "$q";
$res1=odbc_exec($connection,$q);
$pac=array();
while($rez=odbc_fetch_array($res1)) {
$pac[]=db_get_pac_data_by_id($rez['COMMISNO']);
}
return $pac;
}[/PHP]
so help me to boost this script or give me some advice
1 1303 Atli 5,058
Expert 4TB
Hi. Welcome to TSDN!
I see no major problems there. But there are a few things that may be slowing it down a little.
The first part of your query has a "where (1=1)", which is completely useless. 1 will always be 1 so you may just as well get rid of that. I'd remove the "where" from there completely and add it later if needed, maybe in like 31.
Also, later in your code you, on lines 33 and 36, you use the trim function twice on the same variables.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Manzanita |
last post by:
Hi.
I'm using boost::numerics::ublas to solve linear symmetric and
hermitian systems (cholesky, qr, etc.). I'm aware that ublas only provide
basic algebra operations (blas1, blas2 and blas3) so...
|
by: Knackeback |
last post by:
task:
- read/parse CSV file
code snippet:
string key,line;
typedef tokenizer<char_separator<char> > tokenizer;
tokenizer tok(string(""), sep);
while ( getline(f, line) ){
++lineNo;...
|
by: derek.google |
last post by:
I hope a Boost question is not too off-topic here. It seems that
upgrading to Boost 1.33 broke some old regex code that used to work. I
have reduced the problem to this simple example:
cout <<...
|
by: ufnuceda |
last post by:
Hello everyone,
I was wondering if any of you have some experience with the boost
library. I am having trouble compiling code with it. Since boost is
being used a lot these days I thought some...
|
by: extrudedaluminiu |
last post by:
Hi,
Is there any group in the manner of the C++ Boost group that works on
the evolution of the C language? Or is there any group that performs an
equivalent function?
Thanks,
-vs
|
by: =?UTF-8?B?SmVucyBNw7xsbGVy?= |
last post by:
(I also posted this to boost-user)
The BGL implementation of breadth-first search uses a dedicated color map.
I had the following idea: Some algorithms don't need to distinguish
black/gray,...
|
by: Soren |
last post by:
Hi!
I'm trying to extend my python program with some C++ code. Right now
I've spent hours just trying to get boost to work!
I'm trying to get the example hello.cpp to work.
Using Windows XP...
|
by: ameyav |
last post by:
Hi All,
I am converting some C code into C++ code. The objective is to improve throughput.
I have some code written in C which serially parses through a list of files, opens each one of them,...
|
by: ameyav |
last post by:
Hi,
MSVC 9
Boost 1.38
I have an existing program that reads text files a line at a time using the std::ifstream and istream& getline ( istream& is, string& str );
Typical file size is ~40mb...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |