Browse Source

Start recording date_received in the database

import/raw
peter@pcc.me.uk 16 years ago
parent
commit
d14dc6d2aa
2 changed files with 16 additions and 2 deletions
  1. +4
    -1
      trunk/docs/include/application.php
  2. +12
    -1
      trunk/tools/application_parser.php

+ 4
- 1
trunk/docs/include/application.php View File

@@ -6,7 +6,7 @@ require_once('DB.php');
class Application{ class Application{
var $authority_id = 0; var $authority_id = 0;
var $council_reference = ""; var $council_reference = "";
var $date_recieved = "";
var $date_received = "";
var $date_scraped =""; var $date_scraped ="";
var $address = ""; var $address = "";
var $postcode = ""; var $postcode = "";
@@ -63,6 +63,7 @@ class Application{
$x = $db->quote($this->x); $x = $db->quote($this->x);
$y = $db->quote($this->y); $y = $db->quote($this->y);
$date_scraped = $db->quote($this->date_scraped); $date_scraped = $db->quote($this->date_scraped);
$date_received = $db->quote($this->date_received);
$map_url = $db->quote($this->map_url); $map_url = $db->quote($this->map_url);


$sql ="insert into application $sql ="insert into application
@@ -79,6 +80,7 @@ class Application{
x, x,
y, y,
date_scraped, date_scraped,
date_recieved,
map_url map_url
) )
values( values(
@@ -94,6 +96,7 @@ class Application{
$x, $x,
$y, $y,
$date_scraped, $date_scraped,
$date_received,
$map_url $map_url
)"; )";


+ 12
- 1
trunk/tools/application_parser.php View File

@@ -135,7 +135,18 @@
//Grab basic data from the xml //Grab basic data from the xml
$application->authority_id = $authority_id; $application->authority_id = $authority_id;
$application->council_reference = $parsed_application->council_reference; $application->council_reference = $parsed_application->council_reference;
$application->date_received = $parsed_application->date_received;

$date_received_dmy = split("/", $parsed_application->date_received);
if (count($date_received_dmy) == 3){
$application->date_received = "$date_received_dmy[2]-$date_received_dmy[1]-$date_received_dmy[0]";
} else {
// Make a best effort attempt to parse the date
$ts = strtotime($parsed_application->date_received);
if ($ts != FALSE && $ts != -1) {
$application->date_received = date("Y-m-d", $ts);
}
}

$application->address = $parsed_application->address; $application->address = $parsed_application->address;
$application->postcode = $parsed_application->postcode; $application->postcode = $parsed_application->postcode;
$application->description = $parsed_application->description; $application->description = $parsed_application->description;


Loading…
Cancel
Save