Commit 4cbb1693 authored by metzlerd's avatar metzlerd
Browse files

Demonstrate entity loads. Type casting for dates, etc.

parent 1ec02075
......@@ -496,6 +496,12 @@ class FrxDataSource{
return $clause;
}
/**
* Perform generic type conversion based on attributes.
* @param $key The token key for parameter replacement.
* @param $value The value of the parameter
* @return Ambigous <NULL, array>
*/
public function parmConvert($key, $value) {
if (isset($this->types[$key]) && $this->types[$key]) {
if ($value === NULL || $value ==='') {
......@@ -503,6 +509,24 @@ class FrxDataSource{
}
else {
switch (strtolower($this->types[$key])) {
case 'date':
$time = @new DateTime($value);
if ($time) {
$value = date_format($time, 'Y-m-d H:i:s');
}
else {
$value = NULL;
}
break;
case 'unixtime':
$time = @new DateTime($value);
if ($time) {
$value = $time->getTimeStamp();
}
else {
$value = NULL;
}
break;
case 'numeric':
case 'flaot':
$value = (float)$value;
......
--ACCESS=access content
SELECT * FROM node
SELECT nid FROM node
WHERE promote=1
AND status=1
ORDER BY sticky DESC, created
LIMIT COALESCE(CAST(:limit AS integer), 10)
--IF=:limit
LIMIT :limit
--ELSE
LIMIT 10
--END
--INFO
type[limit]=int
entity_type = node
entity_id = nid
\ No newline at end of file
......@@ -2,11 +2,7 @@
SELECT nid, type, title, uid, sticky, promote from node WHERE type=:content_type
and status=1
ORDER BY title
--IF=:limit
LIMIT :limit
--INFO
; This demonstrates loading node entities.
entity_type = node
entity_id = nid
; the following demonstrates an optional limit clause that can be used with SQL
type[limit] = int
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment