| Index
» Projects
» phpMyEdit
» Forum
» PHP Expressions not working for Table List |
 |
t22harris
Joined: 19 Mar 2009
Posts: 15
Posted: 2011-06-03 08:25
Back to top
Reply with quote
|
I have an indirect lookup (Join) that is two tables down. Using a PHP Expression it is working fine for Add, Change and View. But, it doesn't work for the Table List. For Table List, the lookup is correct for the first record and then that same value is incorrectly repeated for every record in the Table. Any advice?
|
t22harris
Joined: 19 Mar 2009
Posts: 15
Posted: 2011-06-03 09:13
Back to top
Reply with quote
|
Using the sql expression does exactly the same thing in list view as does the php expression. The first result found is repeated for all rows in the table. This must be a general limitation of the list_table() function?
| Code: |
$opts['fdd']['reservation_id'] = array(
'name' => 'Reservation ID',
'php|ACV' => 'selectReservationId.php',
'sql|L' => '(SELECT `visitors`.`lastName`
FROM (`payments`, `reservations`, `visitors`)
WHERE (`payments`.`reservation_id` = `reservations`.`id` AND `reservations`.`visitorCode` = `visitors`.`id`)
LIMIT 1) ',
'options' => 'VCAL',
'select' => 'T',
'maxlen' => 11,
'sort' => true
); |
|
t22harris
Joined: 19 Mar 2009
Posts: 15
Posted: 2011-06-03 18:06
Back to top
Reply with quote
|
I had to modify the phpMyEdit.class.php to get the PHP Expression to function properly in Table List. In
function list_table()
I added:
| Code: |
else if($this->col_has_php($k)){
$this->rec = $key_rec;
include($this->fdd[$k]['php']);
}
|
inside the column iterator. This now calls the php function for each row on the list table. However,
$this->rec
was not available so I used
$key_rec
to set it.
Also I'm wondering why
$this->operation
is empty for the list table operation? The fact that it is empty is what I had to use in the php code to detect the list operation.
Bottom line, the code is doing what I need it to do now.
|
doug
Joined: 10 Feb 2003
Posts: 1013
Location: Denver, Colorado (USA)
Posted: 2011-06-04 14:33
Back to top
Reply with quote
|
That's a nice fix. Congratulations. Hopefully this will appear in the CVS in a future update.
|
kayvaan
Joined: 01 Dec 2011
Posts: 1
Posted: 2011-12-01 13:50
Back to top
Reply with quote
|
| t22harris wrote: |
I had to modify the phpMyEdit.class.php to get the PHP Expression to function properly in Table List. In
function list_table()
I added:
| Code: |
else if($this->col_has_php($k)){
$this->rec = $key_rec;
include($this->fdd[$k]['php']);
}
|
inside the column iterator. This now calls the php function for each row on the list table. However,
$this->rec
was not available so I used
$key_rec
to set it.
Also I'm wondering why
$this->operation
is empty for the list table operation? The fact that it is empty is what I had to use in the php code to detect the list operation.
|
Hi t22harris,
I've tried your solution several times, but I'm afraid I can't find the right place inside function list_table to put your code.
Please, could you explain me where I must put that code?
Thanks.
|
t22harris
Joined: 19 Mar 2009
Posts: 15
Posted: 2011-12-01 17:28
Back to top
Reply with quote
|
In the phpMyEdit.class.php in the list_table() funcntion and around line 2440 (I've added so much to my class elsewhere that this line# is now just a guess). My three additional lines are shown here in context:
| Code: |
for ($k = 0; $k < $this->num_fds; $k++) { /* {{{ */
$fd = $this->fds[$k];
if (! $this->displayed[$k]) {
continue;
}
$css_postfix = @$this->fdd[$k]['css']['postfix'];
$css_class_name = $this->getCSSclass('cell', null, true, $css_postfix);
if ($this->password($k)) {
echo '<td class="',$css_class_name,'">',$this->labels['hidden'],'</td>',"\n";
continue;
}
// added by Bob
echo '<td class="',$css_class_name,'"',$this->getColAttributes($fd),'>';
if($this->col_has_dateformat($k))
echo $this->process_date($this->cellDisplay($k, $row, $css_class_name),false);
elseif($this->col_has_php($k)){
$this->rec = $key_rec;
include($this->fdd[$k]['php']);
}else
echo $this->cellDisplay($k, $row, $css_class_name);
echo '</td>',"\n";
} /* }}} */ |
|
|
Post new topic
Reply to topic
|
|
|
|