Re: Basic Dual Query Combine into one question
| From: | dealTek | Date: | Thu, 05 Feb 2015 22:10:15 +0000 |
| Subject: | Re: Basic Dual Query Combine into one question | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-324392@lists.php.net to get a copy of this message | ||
Hi,
Thanks for all the help - now I am up and running with sorting the filemaker query results!
regular text is sorting well - however the "Test_Date" field sorts with no errors but as
text not a date (comes in from filemaker as ex: "1/25/2015" etc.)
this = no errors but just does TEXT sort
$a->getField('Test_Date'),
$b->getField('Test_Date')
I tried this = shows errors and fails (from filemaker query)
$a->strtotime(getField('Test_Date')),
$b->strtotime(getField('Test_Date'))
error....
Fatal error: Call to undefined method FileMaker_Record::strtotime() in /xxxx.php on line 292
BTW: i even tried this just to see and it still has same error...
$a->strtotime('12/12/2012'),
$b->strtotime('12/12/2012')
ALSO strtotime() works fine later in the display loop = <?php echo
strtotime($tests_row->getField('Test_Date',0)); ?>
???? Q: Is there a better way to script this sort this field as a DATE not TEXT?
-------------------
<?php
$records = $tests_result->getRecords();
// 2 field sort
function cmp($a, $b)
{
$result = strcmp(
// !!!!!! errors ???? how do I fix?
$a->strtotime(getField('Test_Date')),
$b->strtotime(getField('Test_Date'))
);
// indifferent, i.e. last names are identical, so sort by state
if (!$result) {
$result = strcmp(
$a->getField('last'),
$b->getField('last')
);
}
/* */
return $result;
}
usort($tests_result->getRecords(), "cmp");
?>