File tree 1 file changed +65
-0
lines changed
1 file changed +65
-0
lines changed Original file line number Diff line number Diff line change @@ -446,6 +446,71 @@ public function getTablesAndRowCounts()
446
446
" );
447
447
}
448
448
449
+ /**
450
+ * List the available values from DPCODES for a given field name
451
+ *
452
+ * @param string $fieldName
453
+ * @return mixed
454
+ */
455
+ public function getFieldValues ($ fieldName )
456
+ {
457
+ $ lastId = 0 ;
458
+ $ finished = false ;
459
+ $ pageSize = 500 ;
460
+ $ result = [];
461
+
462
+ do {
463
+ $ response = $ this ->callSql ("
464
+ SELECT TOP $ pageSize
465
+ *
466
+ FROM
467
+ DPCODES
468
+ WHERE
469
+ field_name = ' $ fieldName'
470
+ AND
471
+ code_id > $ lastId
472
+ ORDER BY
473
+ code_id
474
+ " );
475
+
476
+ if (is_array ($ response )) {
477
+ $ recordsReturned = count ($ response );
478
+ if ($ recordsReturned > 0 ) {
479
+ $ result += $ response ;
480
+
481
+ if ($ recordsReturned < $ pageSize ) {
482
+ $ finished = true ;
483
+ } else {
484
+ $ lastId = end ($ response )->code_id ;
485
+ }
486
+ } else {
487
+ $ finished = true ;
488
+ }
489
+ } else {
490
+ $ finished = true ;
491
+ }
492
+ } while (!$ finished );
493
+
494
+ return $ result ;
495
+ }
496
+
497
+ /**
498
+ * Get all the data for the provided donor
499
+ *
500
+ * @param int $donorId
501
+ * @return array|null
502
+ */
503
+ public function getDonor ($ donorId )
504
+ {
505
+ return $ this ->callSql ("
506
+ SELECT TOP 1
507
+ *
508
+ FROM
509
+ DP
510
+ WHERE donor_id = $ donorId
511
+ " );
512
+ }
513
+
449
514
/**
450
515
* List all available donors in the system.
451
516
*
You can’t perform that action at this time.
0 commit comments