本文整理汇总了PHP中DBAccess::find_by_sql方法的典型用法代码示例。如果您正苦于以下问题:PHP DBAccess::find_by_sql方法的具体用法?PHP DBAccess::find_by_sql怎么用?PHP DBAccess::find_by_sql使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBAccess
的用法示例。
在下文中一共展示了DBAccess::find_by_sql方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateGeoJson
public function generateGeoJson($sql, $gp_name)
{
global $database;
if (strlen(trim($parameters)) > 0) {
if ($gp_name == "intersects" || $gp_name == "split" || $gp_name == "bbox") {
$sql .= " AND " . $parameters;
} else {
$sql .= " WHERE " . $parameters;
}
}
if (strlen(trim($orderby)) > 0) {
$sql .= " ORDER BY " . pg_escape_string($orderby) . " " . $sort;
}
if (strlen(trim($limit)) > 0) {
$sql .= " LIMIT " . pg_escape_string($limit);
}
if (strlen(trim($offset)) > 0) {
$sql .= " OFFSET " . pg_escape_string($offset);
}
$rs = DBAccess::find_by_sql($sql);
$output = '';
$rowOutput = '';
while ($row = $database->fetch_array($rs)) {
$rowOutput = (strlen($rowOutput) > 0 ? ',' : '') . '{"type": "Feature", "geometry": ' . $row['gp_geom'] . ', "properties": {';
$props = '';
$id = '';
foreach ($row as $key => $val) {
if ($key != "geojson") {
$props .= (strlen($props) > 0 ? ',' : '') . '"' . $key . '":"' . escapeJsonString($val) . '"';
}
if ($key == "id") {
$id .= ',"id":"' . escapeJsonString($val) . '"';
}
}
$rowOutput .= $props . '}';
$rowOutput .= $id;
$rowOutput .= '}';
$output .= $rowOutput;
}
$output = '{ "type": "FeatureCollection", "features": [ ' . $output . ' ]}';
return $output;
}