[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] CVS: etemplate/inc class.so_sql.inc.php,1.4,1.5
From: |
Ralf Becker <address@hidden> |
Subject: |
[Phpgroupware-cvs] CVS: etemplate/inc class.so_sql.inc.php,1.4,1.5 |
Date: |
Wed, 16 Apr 2003 10:32:20 -0400 |
Update of /cvsroot/phpgroupware/etemplate/inc
In directory subversions:/tmp/cvs-serv17787
Modified Files:
class.so_sql.inc.php
Log Message:
added possibility to use a sql query-string to so_sql::search
Index: class.so_sql.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/etemplate/inc/class.so_sql.inc.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** class.so_sql.inc.php 27 Mar 2003 17:21:58 -0000 1.4
--- class.so_sql.inc.php 16 Apr 2003 14:32:15 -0000 1.5
***************
*** 381,403 ****
@abstract searches db for rows matching searchcriteria
@discussion '*' and '?' are replaced with sql-wildcards '%' and '_'
! @param $criteria array of key and data cols
@param $only_keys True returns only keys, False returns all cols
@param $order_by fieldnames + {ASC|DESC} separated by colons ','
@param $wildcard string appended befor and after each criteria
@param $empty False=empty criteria are ignored in query, True=empty
have to be empty in row
@result array of matching rows (the row is an array of the cols) or
False
*/
! function
search($criteria,$only_keys=True,$order_by='',$extra_cols='',$wildcard='',$empty=False)
{
! $criteria = $this->data2db($criteria);
!
! foreach($this->db_cols as $db_col => $col)
! { //echo "testing col='$col',
criteria[$col]='".$criteria[$col]."'<br>";
! if (isset($criteria[$col]) && ($empty ||
$criteria[$col] != ''))
! {
! $query .= ($query ? ' AND ' : ' WHERE ') .
$db_col .
! ($wildcard ||
strstr($criteria[$col],'*') || strstr($criteria[$col],'?') ?
! " LIKE
'$wildcard".strtr(str_replace('_','\\_',addslashes($criteria[$col])),'*?','%_')."$wildcard'"
:
! "='".addslashes($criteria[$col])."'");
}
}
--- 381,411 ----
@abstract searches db for rows matching searchcriteria
@discussion '*' and '?' are replaced with sql-wildcards '%' and '_'
! @param $criteria array of key and data cols, OR a SQL query (content
for WHERE), fully quoted (!)
@param $only_keys True returns only keys, False returns all cols
@param $order_by fieldnames + {ASC|DESC} separated by colons ','
+ @param $extra_cols string to be added to the SELECT, eg. (count(*) as
num)
@param $wildcard string appended befor and after each criteria
@param $empty False=empty criteria are ignored in query, True=empty
have to be empty in row
+ @param $op defaults to 'AND', can be set to 'OR' too, then criteria's
are OR'ed together
@result array of matching rows (the row is an array of the cols) or
False
*/
! function
search($criteria,$only_keys=True,$order_by='',$extra_cols='',$wildcard='',$empty=False,$op='AND')
{
! if (!is_array($criteria))
! {
! $query = ' WHERE '.$criteria;
! }
! else
! {
! $criteria = $this->data2db($criteria);
! foreach($this->db_cols as $db_col => $col)
! { //echo "testing col='$col',
criteria[$col]='".$criteria[$col]."'<br>";
! if (isset($criteria[$col]) && ($empty ||
$criteria[$col] != ''))
! {
! $query .= ($query ? " $op " : ' WHERE
') . $db_col .
! ($wildcard ||
strstr($criteria[$col],'*') || strstr($criteria[$col],'?') ?
! " LIKE
'$wildcard".strtr(str_replace('_','\\_',addslashes($criteria[$col])),'*?','%_')."$wildcard'"
:
!
"='".addslashes($criteria[$col])."'");
! }
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] CVS: etemplate/inc class.so_sql.inc.php,1.4,1.5,
Ralf Becker <address@hidden> <=