| Index
» Projekty
» phpMyEdit
» Fórum
» Need to add an IF statement to virtual field |
 |
kally
Založený: 05.01.2005
Príspevky: 14
Zaslal: 2010-05-02 04:41
Návrat hore
Odpovedať s citátom
|
I have a table with information about uploaded images:
id smallint(4),
category varchar(30),
subcategory varchar(30),
img_type varchar(15),
filename varchar(40),
image varchar(75),
width varchar(6),
height varchar(6)
I have another table that has a field in common (PMEtable0.filename = $itemsTable.image) and another field called display that has either a yes or no value.
In order to see the "display" column of the second table I have the following code:
$opts['fdd']['virtual4'] = array(
'name' => 'Set to Display?',
'input' => 'R',
'sort' => true,
'sql' => "(SELECT a.display FROM ".$itemsTable." as a, ".$imagesTable." as b WHERE b.id LIKE PMEtable0.id AND a.image = b.filename )"
);
This works fine. But, not all of the images are listed in both tables. So, while most query results will return a yes or no, if there is no result, I get a blank field. Instead of a blank field I would like to display text, maybe something like "Not in Database".
I have tried to do this using sqlw but am not coming up with something that works.
I tried:
'sqlw' => 'IF($val_qas = "", "Not in Database", $val_qas)'
But get nothing. Am I misunderstanding the way this can be used or is my syntax wrong?
Do you think I need to use a trigger or php? Since this is a virtual field I wasn't sure what would work or what to do.
Thank you for any advice you can give.
|
Malino
Založený: 23.02.2010
Príspevky: 7
Zaslal: 2010-05-26 11:02
Návrat hore
Odpovedať s citátom
|
Try this:
| Kód: |
SELECT ifnull(a.display, "na database entry")
FROM ".$itemTable." AS a
LEFT JOIN ".$imageTable." AS b ON a.image = b.filename
WHERE b.id LIKE PMEtable0.id |
|
|
Odoslať novú tému
Odpovedať na tému
|
|
|
|