[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: |
Sun, 28 Sep 2003 21:46:10 -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: Mon 09/29/2003 at 01:46 (GMT)
------------------ Additional Follow-up Comments ----------------------------
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.
=================== BUG #5599: FULL BUG SNAPSHOT ===================
Submitted by: jecinc Project: phpGroupWare
Submitted on: Sun 09/28/2003 at 02:12
Category: API - phpGWapi Bug Group: None
Severity: 5 - Major Priority: None
Resolution: None 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: 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/
- [Phpgroupware-tracker] [bug #5599] error when using concat function, nobody, 2003/09/27
- [Phpgroupware-tracker] [bug #5599] error when using concat function, nobody, 2003/09/28
- [Phpgroupware-tracker] [bug #5599] error when using concat function,
nobody <=
- [Phpgroupware-tracker] [bug #5599] error when using concat function, nobody, 2003/09/29
- [Phpgroupware-tracker] [bug #5599] error when using concat function, nobody, 2003/09/29
- [Phpgroupware-tracker] [bug #5599] error when using concat function, nobody, 2003/09/29
- [Phpgroupware-tracker] [bug #5599] error when using concat function, nobody, 2003/09/30