/[cvs]/nfo/php/libs/org.netfrag.glib/DataSource/Generic.php
ViewVC logotype

Contents of /nfo/php/libs/org.netfrag.glib/DataSource/Generic.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.9 - (show annotations)
Thu Mar 27 16:24:26 2003 UTC (21 years, 3 months ago) by jonen
Branch: MAIN
Changes since 1.8: +37 -5 lines
+ mugled namespace
+ added enhanced 'queryData'

1 <?php
2 /**
3 * This file contains the GenericDataSource child class
4 *
5 * @author Andreas Motl <andreas.motl@ilo.de>
6 * @package org.netfrag.glib
7 * @name DataSource::Generic
8 *
9 */
10
11 /**
12 * <b>Cvs-Log:</b>
13 *
14 * <pre>
15 * $Id: Generic.php,v 1.8 2003/03/20 07:22:14 jonen Exp $
16 *
17 * $Log: Generic.php,v $
18 * Revision 1.8 2003/03/20 07:22:14 jonen
19 * + modified case 'object' to 'objects'
20 * (cause its loads all *objects* of a given classname)
21 *
22 * Revision 1.7 2003/03/11 01:43:00 joko
23 * + fixed metadata for phpDocumentor
24 *
25 * Revision 1.6 2003/03/11 01:22:25 joko
26 * + fixed metadata for phpDocumentor
27 *
28 * Revision 1.5 2003/03/11 00:12:49 joko
29 * + fixed metadata for phpDocumentor
30 *
31 * Revision 1.4 2003/03/10 23:25:03 joko
32 * + fixed metadata for phpDocumentor
33 *
34 * Revision 1.3 2003/03/09 15:50:36 joko
35 * + additional metadata for Autodia
36 *
37 * Revision 1.2 2003/03/05 17:28:43 joko
38 * updated docu (phpDocumentor testing....)
39 *
40 * Revision 1.1 2003/03/05 12:04:00 joko
41 * + initial commit, from GenericDataSource
42 *
43 * Revision 1.3 2003/03/03 21:24:18 joko
44 * now based on DesignPattern::RemoteProxy
45 *
46 * Revision 1.2 2003/03/02 01:05:13 joko
47 * - purged old code
48 *
49 * Revision 1.1 2003/03/01 21:47:15 joko
50 * renamed from AbstractDataSource.inc
51 *
52 * Revision 1.1 2003/03/01 20:17:15 joko
53 * renamed from GenericDataSource.inc
54 * replaced '_proxy' through '_handler' to better associate the ability to act as a generic dispatcher handler
55 *
56 * Revision 1.3 2003/03/01 15:36:11 joko
57 * + debugging
58 * + renamed some methods regarding new proposal (build_handler_options, fetch_result, etc.)
59 *
60 * Revision 1.2 2003/03/01 04:50:27 joko
61 * encapsulated all output into tracing mode
62 * disabled tracing
63 *
64 * Revision 1.1 2003/03/01 03:10:40 joko
65 * + initial commit
66 * </pre>
67 *
68 */
69
70 /**
71 * This requires the MemoryDataSource base class
72 *
73 */
74
75 // V1: compile-time-include, stable since years ;-)
76 //include_once($phphtmllib."/widgets/data_source/MemoryDataSource.inc");
77
78 // V2: runtime-load proposal, more flexible
79 // loadModule('MemoryDataSource', 'inc'); // doesn't work (would do if basepath of module is in libpath)
80 // loadModule($phphtmllib . '::widgets::data_source::MemoryDataSource', 'inc'); // works (by accident)
81 // loadModule($phphtmllib . "/widgets/data_source/MemoryDataSource", "inc"); // works (should be stable)
82 // loadModule($phphtmllib . "/widgets/data_source/MemoryDataSource.inc", null); // works (should be stable)
83
84
85
86 /**
87 * Have to have PEAR and DB included
88 * the pear dir must be in the
89 * include path.
90 */
91 // require_once("PEAR.php"); // FIXME: what about PEAR::XML::RPC?
92 // require_once("DB.php");
93
94
95 loadModule('DesignPattern::Proxy');
96 loadModule('DesignPattern::TransparentProxy');
97 loadModule('DesignPattern::RemoteProxy');
98
99 //class GenericDataSource extends MemoryDataSource {
100 //class GenericDataSource extends DesignPattern_Proxy {
101 //class GenericDataSource extends DesignPattern_RemoteProxy {
102 //class GenericDataSource extends DesignPattern_TransparentProxy {
103
104 //class GenericDataSource extends MemoryDataSource {
105 //loadModule("DataSource::Proxy::Memory");
106 //class GenericDataSource extends DataSource_Proxy_Memory {
107 //class DataSource_GenericDataSource extends DataSource_Proxy_Memory {
108 //class DataSource_GenericDataSource extends DesignPattern_Proxy {
109 //class DataSource_GenericDataSource extends DataSource_Proxy_Memory {
110
111 // now independent!!! new class-inheritance-tree possible now!
112 // solved by having an Adapter *and* a Proxy here!
113 //class GenericDataSource {
114
115 loadModule('DesignPattern::AdapterProxy');
116
117
118
119 /**
120 * This GenericDataSource child class is *completely* independent
121 * of a specific storage implementation and intended to be a wrapper
122 * class on the way from phpHtmlLib to Xyz. <br>
123 * ("Yyz" gets represented by Data::Storage by now.....)
124 *
125 * GenericDataSource interacts with an intermediate "proxy" object
126 * (e.g. Data::Driver::Proxy) when doing queries. <br>
127 * <pre>
128 * Don't mix this up with a persistent database handle which gets
129 * reused each and every time for different queries.
130 * Here *is* a new instance of Data::Driver::Proxy for *each* query.
131 * </pre>
132 *
133 * But the point is: Caching! The actual *data* isn't read redundant!
134 *
135 * <pre>
136 * --- snipped into here from above ---
137 * that may use arbitrary code modules as database handlers.
138 * It's aims are to get together:
139 * o phpHtmlLibs "source-handlers"
140 * o PEAR's database handlers
141 * o custom ones (e.g. Data::Driver::Proxy object, which talks to a remote rpc server)
142 * --- snipped into here from above ---
143 * </pre>
144 *
145 * <p>
146 * !!!!!! refactor this to Data::Driver::Proxy !!!!!! <-----------------
147 *
148 * Data::Driver::Proxy instantiates "handlers" below itself
149 * which act as encapsulated workers to actually do the stuff to do.
150 * It can cache data for "disconnected mode" using the
151 * php PEAR DB abstraction objects.
152 * One worker already implemented is Data::Driver::RPC::Remote, which
153 * talks to a RPC::XML server (todo: talk SOAP!) using PEAR::XML::RPC.
154 *
155 * <pre>
156 * --- refactored here, but: redundant somehow ---
157 * Data::Driver::Proxy uses a PEAR XML::RPC object to actually
158 * talk HTTP and serialize data chunks to and from XML,
159 * but adds some caching to this "process of fetching data from a remote side".
160 * It "proxies" arbitrary data chunks a) inside a native php4 session,
161 * b) by talking to a rdbms (single proxy-table) or c) [TODO] using PEAR::Cache.
162 * --- refactored here, but: redundant somehow ---
163 * </pre>
164 *
165 * !!!!!! refactor this to Data::Driver::Proxy !!!!!! <-----------------
166 * </p>
167 *
168 *
169 * <p>
170 * <b>How to use?</b>
171 *
172 * Pass an array holding "locator metadata" to the constructor.
173 * GenericDataSource takes care of the rest.
174 *
175 * <pre>
176 * Pass an array to the constructor: (e.g.)
177 *
178 * 1. doing rpc-calls....
179 * <code>
180 * $locator = array(
181 * type => 'rpc',
182 * metadata => array( Host => 'localhost', Port => '8765' ),
183 * );
184 * $source = ne w GenericDataSource($locator);
185 * $this->set_data_source( &$source );
186 * </code>
187 *
188 * 2. [proposal] common datahandles....
189 * <code>
190 * $locator = array(
191 * type => 'mysql',
192 * dsn => 'known dsn markup',
193 * );
194 * $source = ne w GenericDataSource($locator);
195 * $this->set_data_source( &$source );
196 * </code>
197 * </pre>
198 * </p>
199 *
200 *
201 * @link http://www.netfrag.org/~joko/
202 * @author Andreas Motl <andreas.motl@ilo.de>
203 *
204 * @link http://www.netfrag.org/~jonen/
205 * @author Sebastian Utz <seut@tunemedia.de>
206 *
207 * @copyright (c) 2003 - All Rights reserved.
208 *
209 * @link http://www.gnu.org/licenses/lgpl.txt
210 * @license GNU LGPL (GNU Lesser General Public License)
211 *
212 *
213 * @package org.netfrag.glib
214 * @subpackage DataSource
215 * @name DataSource::Generic
216 *
217 * @todo this:
218 * o mungle this to be able to be wrapped around phpHtmlLib's own storage-handles
219 * o implement another Data::Driver::Proxy container
220 *
221 * <pre>
222 * !!!!!!!! THIS IS THE PROBLEM !!!!!!!!
223 * !!!!!!!! here is it where we have to break inheritance again !!!!!!!!
224 *
225 * THE CONFLICT: Beeing in phpHtmlLib *and* DesignPattern::TransparentProxy
226 * inheritance trees at the same time, which is *not* possible at
227 * declare-time. We *do* need some runtime-infrastructure to solve this!
228 *
229 * TODO: move build- and check-locator stuff from ObjectList to this place!!!
230 *
231 * ABOUT:
232 * 1. otherwhere: WebApp - scope:
233 * x handles page vs. block vs. widget; dispatches MVC-View
234 * 2. here: DataSource - scope:
235 * x handles bridge to frameworks (e.g. phpHtmlLib) vs. actual data driver libs (PEAR, etc.))
236 * o clean implementation using a DesignPattern::AdapterProxy
237 * </pre>
238 *
239 *
240 */
241 class DataSource_Generic extends DesignPattern_AdapterProxy {
242
243 // !!!!!!!! here is it where we have to break inheritance again !!!!!!!!
244 // !!!!!!!! THIS IS THE PROBLEM !!!!!!!!
245
246
247
248 /**
249 * This var holds the locator metadata hash
250 * that is used to feed metadata to a per-query-instance
251 * of an Adapter object.
252 *
253 */
254 //var $_locator = NULL;
255
256 /**
257 * This var holds the locator metadata hash
258 * which is built from some predefined rules
259 * using metadata from $_options and some
260 * other presets.
261 *
262 * See '_buildLocator' which acts as a dispatcher
263 * depending on $_options[datasource].
264 * (main dispatching level)
265 *
266 * The structure of a full blown locator looks like this:
267 *
268 * $locator = array(
269 * type => '<your type specifying the datasource-type>',
270 * metadata => array(
271 * ... your arbitrary deep metadata structure ...
272 * ),
273 * [dsn => '<your dsn markup>'],
274 * );
275 *
276 * Example 1 - data is inside a rdbms, using a dsn to connect to it:
277 * $locator = array(
278 * type => 'sql',
279 * dsn => 'mysql://username:password@localhost/database',
280 * );
281 *
282 * Example 2 - data is inside an odbms, reachable by doing remote procedure calls (rpc):
283 * $locator = array(
284 * type => 'rpc',
285 * metadata => array(
286 * package => 'Data::Driver::Proxy',
287 * Host => 'localhost',
288 * Port => '8765',
289 * )
290 * );
291 *
292 */
293 var $_locator = NULL;
294
295
296 /**
297 * This var holds the module information required to
298 * create instances of a Proxy and an Adapter.
299 * Information might get extracted from a
300 * DataSource::Locator instance.
301 *
302 * --- A skeleton:
303 *
304 * $this->_modules = array(
305 * _proxy => array( _id => '', _module => '', _options = array(), _instance => &$obj),
306 * _adapter => array( _id => '', _module => '', _options = array(), _instance => &$obj),
307 * );
308 *
309 *
310 * --- An example:
311 *
312 * $this->_modules = array(
313 * _proxy => array( _id => 'rpc', _module => 'DesignPattern::RemoteProxy', _instance => &$obj),
314 * _adapter => array( _id => 'phpHtmlLib', _module => 'DataSource::Adapter::phpHtmlLib::DataListSource', _instance => &$obj),
315 * );
316 *
317 *
318 */
319 //var $_modules = NULL;
320
321
322 /**
323 * This var holds the query hash
324 * that is used to feed as query to a per-query-instance
325 * of a Data::Driver::Proxy object.
326 *
327 */
328 var $_query = NULL;
329
330
331 /**
332 * this holds the query result from the
333 * Data::Driver::Proxy->queryXyz() call
334 *
335 */
336 var $_result = NULL;
337
338
339
340 /**
341 * The constructor is used to pass in the
342 * locator metadata hash.
343 *
344 * @param LocatorMetadataHash array - layout: array( type => '', metadata => '', dsn => '' )
345 * @param Query array - layout: array( type => '', metadata => '', dsn => '' )
346 */
347
348
349 function DataSource_Generic( &$locator, $query ) {
350
351 // copy parameter from query to locator
352 //$this->_locator->merge_to($this->_locator, array( datasource_type => $query[datasource] ), '_');
353 //$this->_locator->_datasource_type = $query[datasource];
354 //$locator[_datasource_type] = $query[datasource];
355
356 /**
357 * <!-- Autodia -->
358 * can do: (this is metadata supplied for Autodia, don't delete!)
359 * $this->_locator = new DataSource_Locator()
360 *
361 */
362
363 // build master locator
364 $this->_locator = php::mkComponent('DataSource::Locator', $locator, array( datasource_type => $query[datasource] ) );
365 //exit;
366 //$this->_locator = php::mkComponent('DataSource::Locator');
367
368 $this->_locator->check();
369
370 // trace
371 //print "locator-obj: " . Dumper($this->_locator);
372 //print "locator-data: " . Dumper($locator_data);
373 //exit;
374
375
376
377 /*
378 $this->_modules = array(
379 _proxy => array( _id => $locator->_datasource_type ),
380 _adapter => array( _id => $locator->_adapter_type ),
381 );
382 */
383
384 //$this->set_locator( $locator );
385 $this->set_query( $query );
386
387
388
389 /*
390 // V1:
391 // pre-flight: establish and check locator metadata
392 $this->_buildLocator();
393 $this->_checkLocator();
394 */
395
396
397
398 // pre-flight: check locator metadata
399 //$locator->build();
400 if (!$this->_locator->check()) {
401 user_error("locator-check failed.");
402 exit;
403 //return;
404 }
405
406 //exit;
407
408
409 /**
410 * <!-- Autodia -->
411 * can do: (this is metadata supplied for Autodia, don't delete!)
412 * $proxy = new DesignPattern_RemoteProxy()
413 *
414 */
415
416
417 // --- Proxy selector/dispatcher ...
418
419 switch ($this->_locator->_datasource_type) {
420 case 'rpc':
421 //$locator_data = $this->_locator->get_metadata();
422 //$this->_modules[_proxy][_options] = array( locator => $this->_locator, query => $query );
423 //$this->_modules[_proxy][_module] = 'DataSource::Proxy::XMLRPC';
424
425 //$this->_modules[_proxy][_module] = 'DesignPattern::RemoteProxy';
426 //$this->_modules[_proxy][_options] = $locator_data;
427
428 //$this->set_component_name('DesignPattern::RemoteProxy');
429 //$this->set_component_options($locator_data);
430
431 $this->set_component_name('DesignPattern::RemoteProxy');
432
433 break;
434 default:
435 user_error("Site::GenericPage: no Proxy could be selected!");
436 break;
437 }
438
439
440
441 /*
442 // V1:
443 // make up dummy args by now
444 $args = array(
445 adapter => 'phpHtmlLib',
446 );
447 */
448
449 // V2: now propagated from caller!
450
451 //print Dumper(array( locator => $locator, query => $query ));
452 //exit;
453
454 //$this->create_adapter($this->module, $this->function, $this->arguments);
455 //$this->set_handler( $this->get_adapter() );
456
457
458 // --- Adapter selector/dispatcher ...
459 // ... resolves this._modules.adapter._id to this._modules.adapter._module
460
461 switch ($locator->_adapter_type) {
462 case 'phpHtmlLib':
463 //$adapter_arguments = $args[title];
464
465 $this->set_adapter_module('DataSource::Adapter::phpHtmlLib::DataSource');
466
467 // in order to let the Adapter communicate with the Proxy,
468 // instantiate a wrapper method in a third namespace via
469 // Exporter::export_symbol(from, to)
470 $this->set_adapter_options($this);
471
472
473 break;
474 default:
475 user_error("DataSource::GenericDataSource: no Adapter could be selected!");
476 break;
477 }
478
479
480
481 // --- module instantiation - Proxy and Adapter
482
483 //user_error("handle proxy here!");
484 //$this->create_proxy();
485
486 //print Dumper($this);
487
488 //print "this: " . Dumper($this);
489
490 // V1:
491 /*
492 $proxy = php::mkComponent($this->_modules[_proxy][_module], $this->_modules[_proxy][_options]);
493 print "proxy: " . Dumper($proxy);
494 //exit;
495 */
496
497 // V2:
498 /*
499 $resultHandle = mkObject('DesignPattern::RemoteProxy', $cache_key, array( key => 1, command => $command, query => $query, remote => 1, rpcinfo => $rpcinfo, cache => array( db => 0, session => 1 ) ) );
500 $result = $resultHandle->getAttributes();
501 return $result;
502 */
503
504 // V3:
505 // $this->set_handler( $proxy );
506
507 // V4: use _component_name & _component_options (proposal from GenericPage)
508 // $this->_component_name = ...
509 // $this->create_handler();
510
511
512 /**
513 * <!-- Autodia -->
514 * can do: (this is metadata supplied for Autodia, don't delete!)
515 * $adapter = new DataSource_Adapter_phpHtmlLib_DataListSource()
516 *
517 */
518
519 // V1:
520 //$this->create_adapter($adapter_module, $this->function, $this->arguments);
521
522 // V2: FIXME - better use V1?
523 $adapter = php::mkComponent($this->get_adapter_module(), $this->get_adapter_options());
524 $this->set_adapter($adapter);
525
526
527
528
529 }
530
531 function make_adapter_transparent() {
532
533 // ... known from Site::Adapter::php::Class:
534
535 // At this place the Adapter becomes a Proxy.
536 // This functionality currently correlates to the
537 // name of our ancestor, DesignPattern::AdapterProxy.
538 // FIXME: move this code to its namespace!!!
539 // FIXME: rename to set_proxy...
540
541 // The reason this has to occour here is required
542 // by the TransparentProxy to actually make the
543 // _handler (_proxy) transparent later....
544 //$this->set_proxy( $this->get_adapter() );
545 }
546
547 /**
548 * Set the metadata information
549 * (a DataSource::Locator) we will use
550 * to build encapsulated instances
551 * of both a Proxy and an Adapter.
552 *
553 * @param LocatorMetadataHash array -
554 *
555 */
556 function set_metadata( &$locator ) {
557 $this->_locator = &$locator;
558 }
559
560 function &get_metadata() {
561 return $this->_locator;
562 }
563
564
565 /**
566 * Set the query metadata hash we will feed *completely*
567 * to an encapsulated Proxy instance.
568 *
569 * @param QueryDeclaration array -
570 *
571 */
572 function set_query( $query ) {
573 $this->_query = $query;
574 }
575
576 /**
577 * Issue remote/proxy call
578 * Stolen from Application_AbstractBackend::_remote_method (RefactoringProposal?)
579 * Tweaked a bit: proxy package now taken from $this->_handler_name
580 *
581 * Create a new instance of a proxy and store it for later reuse.
582 * Read the locator metadata hash and create
583 * the proxy handler instance using passed-in name.
584 *
585 * @param string - $proxy_name (namespaced classname - perl syntax - e.g.: Data::Driver::Proxy)
586 *
587 */
588 function datasource_handler_call() {
589
590
591 // 1. read args and build cache key
592
593 $arg_list = func_get_args();
594 $command = array_shift($arg_list);
595 $cache_key = join("-", array(session_id(), $command, join('_', $arg_list) ));
596 //print "cache_key: $cache_key<br>";
597
598 // FIXME: what if arg_list still contains more elements after doing this?
599 $query = array_shift($arg_list);
600
601 // 2. prepare proxy-options (read from locator)
602
603 //print "this: " . Dumper($this);
604 //exit;
605
606 // read from locator metadata
607 //$proxy_name = $this->_locator[metadata][package];
608
609 // V1:
610 //$rpcinfo = array( Host => $this->_locator[metadata][Host], Port => $this->_locator[metadata][Port] );
611
612 // V2:
613 $rpcinfo = $this->_locator->get_metadata();
614
615 // FIXME! implement this into Data::Driver::RPC::Remote!
616 //$rpcinfo[to_latin] = 1;
617
618 // FIXME! patch query
619 if (sizeof($query) == 1) {
620 $query = $query[0];
621 }
622
623 //print "query: " . Dumper($query);
624
625 // !!! use DesignPattern::Proxy here !!!
626 // $proxy = new DesignPattern_Proxy($proxy_name, ...)
627 // or:
628 // $proxy = mkObject('DesignPattern::Proxy');
629 // $this->set_handler( $proxy );
630 // or:
631 // $proxy = mkObject('DesignPattern::Proxy');
632 // $proxy->
633 // $this->set_handler( $proxy );
634
635
636
637 //$this->set_component_name( $proxy_name );
638 $this->set_component_options( $cache_key, array( key => 1, command => $command, query => $query, remote => 1, rpcinfo => $rpcinfo, cache => array( db => 0, session => 1 ) ) );
639 //print Dumper($this);
640 //exit;
641
642 $this->create_proxy();
643
644 //print Dumper($this);
645 //exit;
646
647 /*
648 // -------------------- clone this & modify ----------
649 $proxy = mkObject($proxy_name, $cache_key, array( key => 1, command => $command, query => $query, remote => 1, rpcinfo => $rpcinfo, cache => array( db => 0, session => 1 ) ) );
650 $this->set_handler( $proxy );
651 //$result = $resultHandle->getAttributes();
652 //return $result;
653 //$this->_result = $resultHandle->getAttributes();
654 //$this->_result = $this->_handler->getAttributes();
655 // -------------------- clone this & modify ----------
656 */
657
658 }
659
660
661 function datasource_handler_buildoptions() {
662
663 //print Dumper($this->_query);
664 //exit;
665
666 // make up a command from metadata
667 // FIXME: abstract this some more (e.g. via a CommandMapper|Registry)
668 switch ($this->_query[metatype]) {
669 case 'data':
670 $command = 'queryData';
671 //$command = 'getObjects'; // FIXME!!!
672 //$this->_locator->set_option('metadata.command', $command);
673 /*
674 $args = array();
675 switch ($this->_query[vartype]) {
676 case 'objects':
677 if (!$this->_query[classname]) {
678 $msg = "_query[vartype] == 'objects' requires _query[classname]";
679 user_error("GenericDataSource::query_data() - failed: " . $msg);
680 }
681 array_push($args, $this->_query[classname]);
682 break;
683 }
684 */
685 $query_args = array();
686 switch ($this->_query[abstract_type]) {
687 case 'list':
688 if (!$this->_query[classname]) {
689 $msg = "_query[vartype] == 'objects' requires _query[classname]";
690 user_error("GenericDataSource::query_data() - failed: " . $msg);
691 }
692 //array_push($query_args, $this->_query[classname]);
693 $query_args[classname] = $this->_query[classname];
694 break;
695 case 'item':
696 if (!$this->_query[classname]) {
697 $msg = "_query[vartype] == 'objects' requires _query[classname]";
698 user_error("GenericDataSource::query_data() - failed: " . $msg);
699 }
700 $query_args[guid] = $this->_query[ident];
701 $query_args[classname] = $this->_query[classname];
702 break;
703 }
704 $args = array(
705 'data_type' => $this->_query[abstract_type],
706 'query_args' => $query_args
707 );
708 break;
709
710 // querySchema
711 case 'schema':
712 //print "Testing schema:" . "<br>";
713 $command = 'querySchema';
714 break;
715 }
716
717
718 /*
719 $this->_query[rpc_command] = $command;
720 $this->_query[rpc_args] = $command;
721 */
722
723 // methods!!!
724 $this->_locator->_call[_method] = $command;
725 $this->_locator->_call[_arguments] = $args;
726
727 //$adapter = $this->get_adapter();
728
729 // trace
730 /*
731 print Dumper(null, '<b>= = = = = = = = = = = = = = = = = = = = = =</b>');
732 print Dumper('datasource_handler_buildoptions', array(
733 "_locator" => $this->_locator,
734 "_query" => $this->_query,
735 "command" => '<b>' . $command . "</b>",
736 "args" => $args
737 ));
738 */
739
740 /*
741 $this->_handler_options = array(
742 method => $command,
743 args => $args,
744 );
745 */
746
747 }
748
749 function &fetch_result() {
750
751 $this->datasource_handler_buildoptions();
752
753 $method = $this->_locator->_call[_method];
754 $args = $this->_locator->_call[_arguments];
755
756 // pre-flight checks
757 if (!$method) {
758 $msg = "Remote command could not be resolved, please pass in or check configuration.";
759 user_error("GenericDataSource::query_data() - failed: " . $msg);
760 return;
761 }
762
763 //print "fetch_result: this->_handler=" . Dumper($this->_handler);
764
765 // do remote call here and get result
766 // FIXME: handle synchronous/asynchronous mode here!!!
767 $this->datasource_handler_call($method, $args);
768
769
770 // TODO: ... = $this->poll_handler_result and $this->get_handler_result
771 $proxy = $this->get_proxy();
772 $this->_result = $proxy->getResult();
773 //print "result: " . Dumper($this->_result); exit;
774
775 $this->_result_count = sizeof($this->_result);
776
777 // trace
778 if ($this->_debug[notice]) {
779 //print "_result = " . Dumper($this->_result);
780 print "DataSource::Generic->_result_count = " . $this->_result_count . "<br/>";
781 }
782
783 return $this->_result;
784
785 }
786
787
788 function &query_data() {
789 //print "query!<br/>";
790 return $this->fetch_result();
791 //$this->handle_result();
792 }
793
794 function query_schema() {
795 user_error("FIXME: query_schema");
796 // $this->datasource_handler_call( ... );
797 }
798
799 function &get_result() {
800 return $this->_result;
801 }
802
803 }
804
805 ?>

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed