Skip to content

Commit b295b52

Browse files
committed
Merge branch 'master' of github.com:DataTables/Editor-PHP
2 parents 2ae5bbc + 1aa5805 commit b295b52

File tree

2 files changed

+33
-8
lines changed

2 files changed

+33
-8
lines changed

Editor.php

+10-5
Original file line numberDiff line numberDiff line change
@@ -2297,6 +2297,7 @@ private function _options($refresh)
22972297
*/
22982298
private function _optionsSearch($http)
22992299
{
2300+
$values = null;
23002301
$field = $this->_find_field($http['field'], 'name');
23012302

23022303
if (!$field) {
@@ -2309,7 +2310,11 @@ private function _optionsSearch($http)
23092310
return;
23102311
}
23112312

2312-
$values = $options->search($this->db(), $http['search']);
2313+
if (isset($http['search'])) {
2314+
$values = $options->search($this->db(), $http['search']);
2315+
} elseif (isset($http['values'])) {
2316+
$values = $options->find($this->db(), $http['values']);
2317+
}
23132318

23142319
if ($values) {
23152320
$this->_out['data'] = $values;
@@ -2441,16 +2446,16 @@ private function _alias($name, $type = 'alias')
24412446
$a = preg_split('/ as /i', $name);
24422447

24432448
return $type === 'alias' ?
2444-
$a[1] :
2445-
$a[0];
2449+
$a[1] :
2450+
$a[0];
24462451
}
24472452

24482453
if (stripos($name, ' ') !== false) {
24492454
$a = preg_split('/ /i', $name);
24502455

24512456
return $type === 'alias' ?
2452-
$a[1] :
2453-
$a[0];
2457+
$a[1] :
2458+
$a[0];
24542459
}
24552460

24562461
return $name;

Editor/Options.php

+23-3
Original file line numberDiff line numberDiff line change
@@ -336,10 +336,10 @@ public function where($_ = null)
336336
*
337337
* @internal
338338
*/
339-
public function exec($db, $refresh, $search = null)
339+
public function exec($db, $refresh, $search = null, $find = null)
340340
{
341341
// If search only, and not a search action, then just return false
342-
if ($this->searchOnly() && $search === null) {
342+
if ($this->searchOnly() && $search === null && $find === null) {
343343
return false;
344344
}
345345

@@ -384,6 +384,10 @@ public function exec($db, $refresh, $search = null)
384384
->get($fields)
385385
->where($this->_where);
386386

387+
if (is_array($find)) {
388+
$q->where_in($value, $find);
389+
}
390+
387391
if (is_string($this->_order)) {
388392
// For cases where we are ordering by a field which isn't included in the list
389393
// of fields to display, we need to add the ordering field, due to the
@@ -402,6 +406,9 @@ public function exec($db, $refresh, $search = null)
402406
}
403407

404408
$q->order($this->_order);
409+
} elseif ($this->_order === true) {
410+
// Attempt to do a database order, needed for "limit()"ed results
411+
$q->order($this->_label[0]);
405412
}
406413

407414
$rows = $q
@@ -464,13 +471,26 @@ public function exec($db, $refresh, $search = null)
464471

465472
return is_numeric($aLabel) && is_numeric($bLabel) ?
466473
($aLabel * 1) - ($bLabel * 1) :
467-
strcmp($aLabel, $bLabel);
474+
strcmp($aLabel, $bLabel);
468475
});
469476
}
470477

471478
return $out;
472479
}
473480

481+
/**
482+
* Get the objects for a set of values.
483+
*
484+
* @param Database $db Database connection
485+
* @param array $ids IDs to get
486+
*
487+
* @return array|bool
488+
*/
489+
public function find($db, $ids)
490+
{
491+
return $this->exec($db, false, null, $ids);
492+
}
493+
474494
/**
475495
* Do a search for data on the source.
476496
*

0 commit comments

Comments
 (0)