Skip to content
Snippets Groups Projects
Commit 892e7ee8 authored by Damien's avatar Damien
Browse files

Merge branch 'develop' of labs.maarch.org:maarch/MaarchCourrier into develop

parents d1153abb bca542c5
No related branches found
No related tags found
No related merge requests found
......@@ -24,6 +24,7 @@
*/
require_once 'class_functions.php';
require_once 'class_db_pdo_statement.php';
class Database extends functions
{
......@@ -162,11 +163,22 @@ class Database extends functions
}
// Set DSN
$this->dsn = $this->driver
. ':host=' . $this->server
. ';port=' . $this->port
. ';dbname=' . $this->database
;
if ($this->driver == 'oci') {
$tns = "(DESCRIPTION = "
. "(ADDRESS_LIST ="
. "(ADDRESS = (PROTOCOL = TCP)(HOST = " . $this->server . ")(PORT = " . $this->port . "))"
. ")"
. "(CONNECT_DATA ="
. "(SERVICE_NAME = " . $this->database . ")"
. ")"
. ")";
$this->dsn = "oci:dbname=" . $tns;
} else
$this->dsn = $this->driver
. ':host=' . $this->server
. ';port=' . $this->port
. ';dbname=' . $this->database;
if (!isset(self::$preparedStmt[$this->dsn])) {
self::$preparedStmt[$this->dsn] = array();
......@@ -357,8 +369,10 @@ class Database extends functions
}
}
}
return $this->stmt;
$myPdoStatement = new MyPDOStatement($this->stmt);
$myPdoStatement->queryArgs = $parameters;
return $myPdoStatement;
}
public function limit_select($start, $count, $select_expr, $table_refs, $where_def='1=1', $other_clauses='', $select_opts='')
......
<?php
/**
* Copyright Maarch since 2008 under licence GPLv3.
* See LICENCE.txt file at the root folder for more details.
* This file is part of Maarch software.
*
*/
/**
* @brief class db pdo statement
* @author dev@maarch.org
* @ingroup core
*/
require_once 'class_db_pdo.php';
class MyPDOStatement
{
private $pdoStatement;
public $queryArgs;
public function __construct($pdoStatement)
{
$this->pdoStatement = $pdoStatement;
}
public function __call($method, array $args=array())
{
if ($method == 'rowCount') {
return $this->nbResult();
} else {
return call_user_func_array(array($this->pdoStatement, $method), $args);
}
}
protected function nbResult()
{
$db = new Database();
switch ($_SESSION['config']['databasetype']) {
case 'POSTGRESQL' :
return $this->pdoStatement->rowCount();
default :
$db = new Database();
$query = "select count(1) as rc from (" . $this->pdoStatement->queryString . ")";
$stmtRC = $db->query($query, $this->queryArgs);
$fetch = $stmtRC->fetchObject();
return $fetch->rc;
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment