2013-04-19 10:03:57 +00:00
|
|
|
<?php
|
|
|
|
class Metadata
|
|
|
|
{
|
|
|
|
private $db; //传入PDO对象.
|
|
|
|
|
|
|
|
//使用到的公共变量
|
2013-11-10 08:34:30 +00:00
|
|
|
public $tbl_metadata = "en.normalmetadata";
|
2013-04-19 10:03:57 +00:00
|
|
|
|
|
|
|
function __construct($db)
|
|
|
|
{
|
|
|
|
$this->db = $db;
|
|
|
|
}
|
|
|
|
|
|
|
|
function view($uuid)
|
|
|
|
{
|
|
|
|
$sql = "SELECT * FROM ".$this->tbl_metadata." WHERE uuid='$uuid'";
|
|
|
|
$rs = $this->db->query($sql);
|
|
|
|
return $rs->fetch();
|
|
|
|
}
|
2013-05-27 08:59:42 +00:00
|
|
|
|
2013-05-30 02:24:36 +00:00
|
|
|
function DatasFilter($options)
|
2013-05-27 08:59:42 +00:00
|
|
|
{
|
|
|
|
$wheresql = array();
|
|
|
|
|
|
|
|
if(isset($options['east']))
|
|
|
|
{
|
|
|
|
$wheresql[] = " md.east < ".$options['east'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if(isset($options['west']))
|
|
|
|
{
|
|
|
|
$wheresql[] = " md.west > ".$options['west'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if(isset($options['north']))
|
|
|
|
{
|
|
|
|
$wheresql[] = " md.north < ".$options['north'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if(isset($options['south']))
|
|
|
|
{
|
|
|
|
$wheresql[] = " md.south > ".$options['south'];
|
|
|
|
}
|
|
|
|
|
2013-05-30 02:24:36 +00:00
|
|
|
if(isset($options['q']))
|
|
|
|
{
|
|
|
|
if(preg_match("/\'/",$options['q']))
|
|
|
|
{
|
|
|
|
$q = preg_replace("/\'/","''",$options['q']);
|
|
|
|
}else{
|
|
|
|
$q = $options['q'];
|
|
|
|
}
|
|
|
|
$wheresql[] = " md.title LIKE '%$q%' ";
|
|
|
|
}
|
|
|
|
|
2013-05-27 08:59:42 +00:00
|
|
|
if(count($wheresql)>0)
|
|
|
|
{
|
|
|
|
$wheresql = " WHERE ".join(" AND ",$wheresql);
|
|
|
|
}else{
|
|
|
|
$wheresql = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
$sql = "SELECT md.* FROM ".$this->tbl_metadata." md $wheresql";
|
|
|
|
|
|
|
|
$rs = $this->db->query($sql);
|
|
|
|
return $rs->fetchAll();
|
|
|
|
}
|
2013-04-19 10:03:57 +00:00
|
|
|
}
|