This topic is locked

Problem with Concat

10/30/2006 4:37:25 AM
PHPRunner General questions
D
dieter author

I used the following statement in PHPRunner 3.0:
function BeforeEdit(&$values)
{
// Parameters:
// $values - Array object.
// Each field on the Edit form represented as 'Field name'-'Field value' pair
// $where - string with WHERE clause pointing to record to be edited
$values["Alles"]="concat('<b>',".$values["Name"].",'</b>, ',".$values["Vorname"].",'
',".$values["Geburtsdatum"].",'
<b><i>',".$values["Wohnort"].",'</b></i>
',".$values["Straße"].",'
',".$values["Geschlecht"].",'
',".$values["Telefon"].")";
//** Custom code ****
// put your custom code here
return true;
// return true if you like to proceed with editing this record
// return false in other case
}
Now there is a problem when I call the field Alles in another Table by using
select `_person`.`ID`,

`Alles`,

`PN`,

`PEID`,

`Bemerkungen`,

`erledigt`

From `_person` inner join `_posteingang` on (`_person`.`PN`=`_posteingang`.`PEID`)
I get a strang view; I see the word concat and then the contents of the fields.
could there be a problem with the qoutes ?
thank you for an answer.
Dieter

Alexey admin 10/30/2006

Dieter,
there is no need to use Concat function there.

Just combine all your values in PHP string.

Here is the code:

$values["Alles"]="<b>".$values["Name"]."</b>".

$values["Vorname"]."<br>".$values["Geburtsdatum"].

"<br><b><i>".$values["Wohnort"]."</b></i><br>".

$values["Straße"]."<br>".$values["Geschlecht"]."<br>".

$values["Telefon"];
D
dieter author 10/30/2006

Thanks
now it works fine, but there is a problem with the Date format. I like to see dd.mm.yyyy and in the combined field "Alles" there is yyyy-mm-dd hh.mm.ss althoug I formated the field "Geburtsdatum" as short date ? <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=12297&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />
Dieter

Alexey admin 10/30/2006

Dieter,
dates in both $values array and database are formatted as YYYY-MM-DD

You can easily reformat them.

Here is the sample code.

$arr = split("[-: ]",$values["Geburtsdatum"]);

while(count($arr)<6)

$arr[]=0;

$date = $arr[2].".".$arr[1].".".$arr[0]." ".$arr[3].":".$arr[4].":".$arr[5];

echo $date;
D
dieter author 10/31/2006

Thank you Alexey this works.
But one last Question.
You can see, that there is an inner join.
.....

From `_person` inner join `_posteingang` on (`_person`.`ID`=`_posteingang`.`PEID`)
PEID is the ID of the person.
When this person is deleted, then there is no view/list of the corresponding values in the table _posteingang.

But there is one "Dummy" Person with ID 1. Is it possible to set this Person with ID 1 as default, when there is no other person found because it was deleted ?
Is it possible to have the warning modified, when the want to delete any person ?
Thank you
Dieter

Alexey admin 10/31/2006

Dieter,
try using RIGHT JOIN instead of INNER JOIN in your SQL query.
If this doesn't help you can update non-connected records to dummy person manually using events.
To change the warning text highlight Delete Selected link in Visual Editor, switch to HTML mode and change the warning text there.