[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-tracker] [bug #5599] error when using concat function
From: |
nobody |
Subject: |
[Phpgroupware-tracker] [bug #5599] error when using concat function |
Date: |
Thu, 02 Oct 2003 00:30:18 -0400 |
User-agent: |
Mozilla/5.0 Galeon/1.2.7 (X11; Linux i686; U;) Gecko/20030131 |
=================== BUG #5599: LATEST MODIFICATIONS ==================
http://savannah.gnu.org/bugs/?func=detailbug&bug_id=5599&group_id=509
Changes by: Johnson <address@hidden>
Date: Thu 10/02/2003 at 04:30 (GMT)
------------------ Additional Follow-up Comments ----------------------------
I screwed it up
It SHOULD be:
$return_value[] = '(CASE WHEN '.$data.' IS NULL THEN '' ELSE '.$data.' END)';
(WHEN is moved and IS is added)
=================== BUG #5599: FULL BUG SNAPSHOT ===================
Submitted by: jecinc Project: phpGroupWare
Submitted on: Sun 09/28/2003 at 02:12
Category: API - phpGWapi Bug Group: 0.9.16RC1
Severity: 5 - Major Priority: None
Resolution: Later Assigned to: eald
Status: Open Component Version: None
Platform Version: None Reproducibility: None
Summary: error when using concat function
Original Submission: Just starting to test this out
Using this code:
include_once(PHPGW_API_INC . '/class.sql.inc.php');
$my_concatenated_field = sql::concat_null( array('org_name', 'first_name',
'last_name') );
results in an error:
Warning: Invalid argument supplied for foreach() in
/home/htdocs/phpgroupware/phpgwapi/inc/class.sql.inc.php on line 422
Follow-up Comments
*******************
-------------------------------------------------------
Date: Thu 10/02/2003 at 04:30 By: jecinc
I screwed it up
It SHOULD be:
$return_value[] = '(CASE WHEN '.$data.' IS NULL THEN '' ELSE '.$data.' END)';
(WHEN is moved and IS is added)
-------------------------------------------------------
Date: Thu 10/02/2003 at 04:25 By: jecinc
One more problem.
In function safe_null($value)
$return_value[] = '(CASE '.$data.' WHEN NULL THEN '' ELSE '.$data.' END)';
the CASE statement doesn't work (only tested in pgsql).
It should be:
$return_value[] = '(CASE WHEN '.$data.' NULL THEN '' ELSE '.$data.' END)';
(the 'WHEN' is moved before the $data)
-------------------------------------------------------
Date: Tue 09/30/2003 at 13:57 By: eald
This has been corrected in CVS.
To grab a complete update of all fixes:
1) Check to see if you have cvs installed: 'cvs --help'.
1a) If not, install a copy of cvs-cli from your favorite
distro.
2) Then just type:
'cd <your phpgroupware dir>; cvs update -dP'.
You can do step 2 as many times in a day as you wish, and
will always get the most current bug fixes.
Thanks,
-------------------------------------------------------
Date: Tue 09/30/2003 at 01:07 By: eald
This has been corrected in CVS.
To grab a complete update of all fixes:
1) Check to see if you have cvs installed: 'cvs --help'.
1a) If not, install a copy of cvs-cli from your favorite
distro.
2) Then just type:
'cd <your phpgroupware dir>; cvs update -dP'.
You can do step 2 as many times in a day as you wish, and
will always get the most current bug fixes.
Thanks,
-------------------------------------------------------
Date: Tue 09/30/2003 at 01:05 By: eald
This has been corrected in CVS.
To grab a complete update of all fixes:
1) Check to see if you have cvs installed: 'cvs --help'.
1a) If not, install a copy of cvs-cli from your favorite
distro.
2) Then just type:
'cd <your phpgroupware dir>; cvs update -dP'.
You can do step 2 as many times in a day as you wish, and
will always get the most current bug fixes.
Thanks,
-------------------------------------------------------
Date: Tue 09/30/2003 at 01:05 By: eald
This has been corrected in CVS.
To grab a complete update of all fixes:
1) Check to see if you have cvs installed: 'cvs --help'.
1a) If not, install a copy of cvs-cli from your favorite
distro.
2) Then just type:
'cd <your phpgroupware dir>; cvs update -dP'.
You can do step 2 as many times in a day as you wish, and
will always get the most current bug fixes.
Thanks,
-------------------------------------------------------
Date: Mon 09/29/2003 at 01:51 By: eald
mmm, I only changed on concat_null function, and seems work here; not necesary
add the increment in $return_value[] array.
Any comment?
-------------------------------------------------------
Date: Mon 09/29/2003 at 01:46 By: jecinc
I rewrote them (this is the pgsql version, the other dbs should be rewritten
too):
function concat_null($elements)
{
$elements = sql::safe_null($elements);
$str = implode(' || ', $elements);
return ($str) ? '(' . $str . ')' : '';
}
function safe_null($value)
{
if(empty($value))
{
return ;
}
$value = is_array($value) ? $value : array($value);
$i=0;
foreach($value as $data)
{
$return_value[$i] = '(CASE '.$data.' WHEN NULL
THEN '' ELSE '.$data.')';
$i++;
}
return $return_value;
}
When time permits, this should be edited to change elements to a two
dimensional array (key => value) so that constants can be included in the
concat and can skip the CASE statement.
I think constants will work with current code, it it just overly complex.
CC list is empty
No files currently attached
For detailed info, follow this link:
http://savannah.gnu.org/bugs/?func=detailbug&bug_id=5599&group_id=509
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/