Changement du modèle SQL : le contenu de content_version est désormais en json (pour pouvoir recevoir les POI), et on a créé la base pour la géométrie à venir des POIs
This commit is contained in:
@@ -66,6 +66,8 @@ class BlogArticle
|
||||
** Populate the object using its ID
|
||||
*****/
|
||||
public function populate($row) {
|
||||
$json = json_decode($row['content'], true);
|
||||
|
||||
$this->content_id = $row['content_id'];
|
||||
$this->locale_id = $row['locale_id'];
|
||||
$this->version_id = $row['version_id'];
|
||||
@@ -80,7 +82,7 @@ class BlogArticle
|
||||
$this->is_commentable = $row['is_commentable'];
|
||||
$this->type = $row['type'];
|
||||
$this->name = $row['name'];
|
||||
$this->content = $row['content'];
|
||||
$this->content = isset($json['text']) ? $json['text'] : '';
|
||||
}
|
||||
|
||||
/*****
|
||||
@@ -110,7 +112,9 @@ class BlogArticle
|
||||
|
||||
pg_prepare($con, "prepare2", $query)
|
||||
or die ("Cannot prepare statement\n");
|
||||
$result = pg_execute($con, "prepare2", array($this->version, date('r'), $this->name, $this->content, $this->locale_id))
|
||||
|
||||
$jsonContent = json_encode(['text' => $this->content]);
|
||||
$result = pg_execute($con, "prepare2", array($this->version, date('r'), $this->name, $jsonContent, $this->locale_id))
|
||||
or die ("Cannot execute statement\n");
|
||||
|
||||
$this->version_id = pg_fetch_assoc($result)['id'];
|
||||
@@ -216,7 +220,9 @@ class BlogArticle
|
||||
|
||||
pg_prepare($con, "prepare3", $query)
|
||||
or die ("Cannot prepare statement\n");
|
||||
$result = pg_execute($con, "prepare3", array(date('r'), $this->name, $this->content, $this->locale_id))
|
||||
|
||||
$jsonContent = json_encode(['text' => $this->content]);
|
||||
$result = pg_execute($con, "prepare3", array(date('r'), $this->name, $jsonContent, $this->locale_id))
|
||||
or die ("Cannot execute statement\n");
|
||||
|
||||
$this->version_id = pg_fetch_assoc($result)['id'];
|
||||
|
||||
@@ -118,7 +118,7 @@ class Poi
|
||||
$this->alt_name = $this->name;
|
||||
$this->alt_position = $this->position;
|
||||
|
||||
$query = "INSERT INTO pois (is_public, permalink, creation_date, name, position, type) VALUES
|
||||
$query = "INSERT INTO contents (is_public, permalink, creation_date, name, position, type) VALUES
|
||||
(TRUE, $1, $2, $3, $4, $5) RETURNING id";
|
||||
|
||||
pg_prepare($con, "prepare1", $query)
|
||||
|
||||
@@ -68,6 +68,8 @@ class WikiPage
|
||||
** Populate the object using raw data from SQL
|
||||
*****/
|
||||
public function populate($row) {
|
||||
$json = json_decode($row['content'], true);
|
||||
|
||||
$this->content_id = $row['content_id'];
|
||||
$this->locale_id = $row['locale_id'];
|
||||
$this->version_id = $row['version_id'];
|
||||
@@ -82,7 +84,7 @@ class WikiPage
|
||||
$this->is_commentable = $row['is_commentable'];
|
||||
$this->type = $row['type'];
|
||||
$this->name = $row['name'];
|
||||
$this->content = $row['content'];
|
||||
$this->content = isset($json['text']) ? $json['text'] : '';
|
||||
}
|
||||
|
||||
/*****
|
||||
@@ -112,7 +114,9 @@ class WikiPage
|
||||
|
||||
pg_prepare($con, "prepare2", $query)
|
||||
or die ("Cannot prepare statement\n");
|
||||
$result = pg_execute($con, "prepare2", array($this->version, date('r'), $this->name, $this->content, $this->locale_id))
|
||||
|
||||
$jsonContent = json_encode(['text' => $this->content]);
|
||||
$result = pg_execute($con, "prepare2", array($this->version, date('r'), $this->name, $jsonContent, $this->locale_id))
|
||||
or die ("Cannot execute statement\n");
|
||||
|
||||
$this->version_id = pg_fetch_assoc($result)['id'];
|
||||
@@ -218,7 +222,9 @@ class WikiPage
|
||||
|
||||
pg_prepare($con, "prepare3", $query)
|
||||
or die ("Cannot prepare statement\n");
|
||||
$result = pg_execute($con, "prepare3", array(date('r'), $this->name, $this->content, $this->locale_id))
|
||||
|
||||
$jsonContent = json_encode(['text' => $this->content]);
|
||||
$result = pg_execute($con, "prepare3", array(date('r'), $this->name, $jsonContent, $this->locale_id))
|
||||
or die ("Cannot execute statement\n");
|
||||
|
||||
$this->version_id = pg_fetch_assoc($result)['id'];
|
||||
|
||||
Reference in New Issue
Block a user