jablonka.czprosek.czf

weathermap

Subversion Repositories:
[/] [lib/] [datasources/] [WeatherMapDataSource_dbsample.php] - Blame information for rev 4

 

Line No. Rev Author Line
11simandl<?php
2// Sample Pluggable datasource for PHP Weathermap 0.9
3// - read a pair of values from a database, and return it
4 
5// TARGET dbplug:databasename:username:pass:hostkey
6 
7class WeatherMapDataSource_dbsample extends WeatherMapDataSource {
8 
9 function Recognise($targetstring)
10 {
11 if(preg_match("/^dbplug:([^:]+):([^:]+):([^:]+):([^:]+)$/",$targetstring,$matches))
12 {
13 return TRUE;
14 }
15 else
16 {
17 return FALSE;
18 }
19 }
20 
21 function ReadData($targetstring, &$map, &$item)
22 {
23 if(preg_match("/^dbplug:([^:]+):([^:]+):([^:]+):([^:]+)$/",$targetstring,$matches))
24 {
25 $database = $matches[0];
26 $db_user = $matches[1];
27 $db_pass = $matches[2];
28 $key = mysql_real_escape_string($matches[3]);
29 
30 $SQL = "select in,out from table where host=$key";
31 }
32 else
33 {
34 return ( array(-1,-1) );
35 }
36 }
37}
38 
39// vim:ts=4:sw=4:
40?>

Powered by WebSVN 2.2.1