}
private function pointerOutput($f, $d, $forEdit = false, $id = false, $idfield = 'id')
{
-
+ static $pointerCache = array();
/*
* This function will only return the value of the pointer field unless one
* of the following situations occurs.
} else {
- $sql = "
- SELECT ".$p_id." AS p_id,
- ".$f['p_field']." AS p_value
- FROM ".$f['p_table']."
- $where
- ORDER BY $order_by
- ";
- $p_list = $this->wpdb->get_results($sql, ARRAY_A);
+ // check the pointerCache
+ if ( isset( $pointerCache['p_list'][$f['p_table']][$f['p_field']][$p_id] ) ) {
+ $p_list = $pointerCache['p_list'][$f['p_table']][$f['p_field']][$p_id];
+ } else {
+ $sql = "
+ SELECT ".$p_id." AS p_id,
+ ".$f['p_field']." AS p_value
+ FROM ".$f['p_table']."
+ $where
+ ORDER BY $order_by
+ ";
+ $p_list = $this->wpdb->get_results($sql, ARRAY_A);
+ }
+ // store results in cache
+ $pointerCache['p_list'][$f['p_table']][$f['p_field']][$p_id] = $p_list;
// Build pick select table
$pick_select = false;
foreach ($p_list as $p) {
$pick_list[$p['p_id']] = array(
- 'value' => $p['p_id'],
- 'name' => $p['p_value'],
- 'nameEsc' => addslashes($p['p_value']),
- 'default' => ($p['p_id'] == $p_value)
+ 'value' => $p['p_id'],
+ 'name' => $p['p_value'],
+ 'nameEsc' => addslashes($p['p_value']),
+ 'default' => ($p['p_id'] == $p_value)
);
// Check for selected option
}
$r = array(
- 'value' => $p_value,
- 'name' => $selected_name,
- 'nameEsc' => addslashes($selected_name),
- 'list' => $pick_list
+ 'value' => $p_value,
+ 'name' => $selected_name,
+ 'nameEsc' => addslashes($selected_name),
+ 'list' => $pick_list
);
return $r;
// Get pointer value, ensure that's it's an integer
$p_value = ($d - 0);
+ // check the pointerCache
+ if ( isset( $pointerCache['default'][$f['p_table']][$f['p_field']][$p_id][$p_value] ) ) {
+ $res = $pointerCache['default'][$f['p_table']][$f['p_field']][$p_id][$p_value];
+ return $res[$f['p_field']];
+ }
+
$sql = "
SELECT ".$f['p_field']."
FROM ".$f['p_table']."
AND $p_id = $p_value
";
$res = $this->wpdb->get_row($sql, ARRAY_A);
+ // store results in cache
+ $pointerCache['default'][$f['p_table']][$f['p_field']][$p_id][$p_value] = $res;
return $res[$f['p_field']];
}
private function pointerInput($as, $f, $id, $idfield, $op)
{
+ static $pointerCache = array();
$this->inputFieldStatus = true;