"Fossies" - the Fresh Open Source Software Archive

Member "papayacms-core-6.12.5/src/system/Papaya/Database/Accessible/Aggregation.php" (7 Jul 2020, 2119 Bytes) of package /linux/www/papayacms-core-6.12.5.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "Aggregation.php" see the Fossies "Dox" file reference documentation.

    1 <?php
    2 /**
    3  * papaya CMS
    4  *
    5  * @copyright 2000-2018 by papayaCMS project - All rights reserved.
    6  * @link http://www.papaya-cms.com/
    7  * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU General Public License, version 2
    8  *
    9  *  You can redistribute and/or modify this script under the terms of the GNU General Public
   10  *  License (GPL) version 2, provided that the copyright and license notes, including these
   11  *  lines, remain unmodified. papaya is distributed in the hope that it will be useful, but
   12  *  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
   13  *  FOR A PARTICULAR PURPOSE.
   14  */
   15 namespace Papaya\Database\Accessible;
   16 
   17 use Papaya\Application;
   18 use Papaya\Database;
   19 
   20 trait Aggregation {
   21   use Application\Access\Aggregation;
   22 
   23   /**
   24    * Database read uri
   25    *
   26    * @var string|null
   27    */
   28   private $_databaseURIs = [
   29     'read' => NULL,
   30     'write' => NULL
   31   ];
   32 
   33   /**
   34    * Stored database access object
   35    *
   36    * @var Database\Access
   37    */
   38   protected $_databaseAccessObject;
   39 
   40   /**
   41    * @param null|string $read
   42    * @param null|string $write
   43    */
   44   public function setDatabaseURIs($read, $write = NULL) {
   45     $this->_databaseURIs = [
   46       'read' => $read,
   47       'write' => $write
   48     ];
   49   }
   50 
   51   /**
   52    * Set database access object
   53    *
   54    * @param Database\Access $databaseAccessObject
   55    */
   56   public function setDatabaseAccess(Database\Access $databaseAccessObject) {
   57     $this->_databaseAccessObject = $databaseAccessObject;
   58   }
   59 
   60   /**
   61    * Get database access object
   62    *
   63    * @return Database\Access
   64    */
   65   public function getDatabaseAccess() {
   66     if (NULL === $this->_databaseAccessObject) {
   67       $this->_databaseAccessObject = $this->createDatabaseAccess();
   68     }
   69     return $this->_databaseAccessObject;
   70   }
   71 
   72   /**
   73    * @return \Papaya\Database\Access
   74    */
   75   private function createDatabaseAccess() {
   76     $databaseAccess = new Database\Access($this, $this->_databaseURIs['read'], $this->_databaseURIs['write']);
   77     if ($this instanceof Application\Access) {
   78       $databaseAccess->papaya($this->papaya());
   79     }
   80     return $databaseAccess;
   81   }
   82 }