From 562387a9e7a29f88be8a4fd2635116ac26d4e7f7 Mon Sep 17 00:00:00 2001 From: edward Date: Wed, 30 Mar 2016 19:04:00 +0800 Subject: [PATCH] RooGetTrait.php --- RooGetTrait.php | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/RooGetTrait.php b/RooGetTrait.php index bbb9b68e..596347fb 100644 --- a/RooGetTrait.php +++ b/RooGetTrait.php @@ -638,4 +638,42 @@ trait Pman_Core_RooGetTrait { return; } + + function meta($x, $data) + { + $lost = 0; + $cols = array_keys($data[0]); + + $options = &PEAR::getStaticProperty('DB_DataObject','options'); + $reader = $options["ini_{$x->_database}"] .'.reader'; + if (!file_exists( $reader )) { + return; + } + + $rdata = unserialize(file_get_contents($reader)); + + $keys = $x->keys(); + $key = empty($keys) ? 'id' : $keys[0]; + + + $meta = array(); + foreach($cols as $c ) { + if (!isset($this->cols[$c]) || !isset($rdata[$this->cols[$c]]) || !is_array($rdata[$this->cols[$c]])) { + $meta[] = $c; + continue; + } + $add = $rdata[$this->cols[$c]]; + $add['name'] = $c; + $meta[] = $add; + } + return array( + 'totalProperty' => 'total', + 'successProperty' => 'success', + 'root' => 'data', + 'id' => $key, // was 'id'... + 'fields' => $meta + ); + + + } } -- 2.39.2