Merge pull request #3 from LeOSW42/copilot/create-database-file-connection
Centralize PostgreSQL connection setup across models
This commit is contained in:
@@ -11,6 +11,7 @@ namespace Kabano;
|
||||
**********************************************************/
|
||||
|
||||
require_once($config['third_folder']."Md/MarkdownExtra.inc.php");
|
||||
require_once($config['includes_folder']."database.php");
|
||||
|
||||
class WikiPage
|
||||
{
|
||||
@@ -51,8 +52,7 @@ class WikiPage
|
||||
public function checkPermalink($permalink, $withArchive=0, $elementNb=0) {
|
||||
global $config;
|
||||
|
||||
$con = pg_connect("host=".$config['SQL_host']." dbname=".$config['SQL_db']." user=".$config['SQL_user']." password=".$config['SQL_pass'])
|
||||
or die ("Could not connect to server\n");
|
||||
$con = sql_connect();
|
||||
|
||||
$query = "SELECT content_versions.id AS version_id, * FROM contents INNER JOIN content_locales ON contents.id = content_locales.content_id INNER JOIN content_versions ON content_locales.id = content_versions.locale_id WHERE permalink=$1 AND type='wiki'";
|
||||
if($withArchive==0) {
|
||||
@@ -149,8 +149,7 @@ class WikiPage
|
||||
|
||||
$this->version++;
|
||||
|
||||
$con = pg_connect("host=".$config['SQL_host']." dbname=".$config['SQL_db']." user=".$config['SQL_user']." password=".$config['SQL_pass'])
|
||||
or die ("Could not connect to server\n");
|
||||
$con = sql_connect();
|
||||
|
||||
pg_query($con, "BEGIN");
|
||||
|
||||
@@ -198,8 +197,7 @@ class WikiPage
|
||||
global $config;
|
||||
global $user;
|
||||
|
||||
$con = pg_connect("host=".$config['SQL_host']." dbname=".$config['SQL_db']." user=".$config['SQL_user']." password=".$config['SQL_pass'])
|
||||
or die ("Could not connect to server\n");
|
||||
$con = sql_connect();
|
||||
|
||||
$query = "UPDATE contents SET is_public=FALSE WHERE permalink=$1 AND type='wiki'";
|
||||
|
||||
@@ -223,8 +221,7 @@ class WikiPage
|
||||
global $config;
|
||||
global $user;
|
||||
|
||||
$con = pg_connect("host=".$config['SQL_host']." dbname=".$config['SQL_db']." user=".$config['SQL_user']." password=".$config['SQL_pass'])
|
||||
or die ("Could not connect to server\n");
|
||||
$con = sql_connect();
|
||||
|
||||
$query = "UPDATE contents SET is_public=TRUE WHERE permalink=$1 AND type='wiki'";
|
||||
|
||||
@@ -248,8 +245,7 @@ class WikiPage
|
||||
global $config;
|
||||
global $user;
|
||||
|
||||
$con = pg_connect("host=".$config['SQL_host']." dbname=".$config['SQL_db']." user=".$config['SQL_user']." password=".$config['SQL_pass'])
|
||||
or die ("Could not connect to server\n");
|
||||
$con = sql_connect();
|
||||
|
||||
pg_query($con, "BEGIN");
|
||||
|
||||
@@ -330,8 +326,7 @@ class WikiPages
|
||||
public function getHistory($url) {
|
||||
global $config;
|
||||
|
||||
$con = pg_connect("host=".$config['SQL_host']." dbname=".$config['SQL_db']." user=".$config['SQL_user']." password=".$config['SQL_pass'])
|
||||
or die ("Could not connect to server\n");
|
||||
$con = sql_connect();
|
||||
|
||||
$query = "SELECT content_versions.id AS version_id, * FROM contents INNER JOIN content_locales ON contents.id = content_locales.content_id INNER JOIN content_versions ON content_locales.id = content_versions.locale_id WHERE permalink=$1 AND type='wiki' ORDER BY update_date DESC";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user