/**
  * Getter for {@see $_backend} property
  * 
  * Lazy loading: Initializes $_backend on first request
  * 
  * @return Setup_Backend_Abstract
  */
 public function getBackend()
 {
     if (!isset($this->_backend)) {
         $this->_backend = Setup_Backend_Factory::factory();
     }
     return $this->_backend;
 }
Example #2
0
 /**
  * This method is necessary only if Oracle is used.
  * @todo discover a way to replace this code for an equivalent in Tinebase_Backend_Sql_Command
  */
 protected function _initProcedures()
 {
     $backend = Setup_Backend_Factory::factory();
     $_db = Tinebase_Core::getDb();
     if ($_db instanceof Zend_Db_Adapter_Oracle) {
         $md5 = "CREATE OR REPLACE\n\t\t\t\tfunction md5( input varchar2 ) return sys.dbms_obfuscation_toolkit.varchar2_checksum as\n\t\t\t\tbegin\n\t\t\t\t\treturn lower(rawtohex(utl_raw.cast_to_raw(sys.dbms_obfuscation_toolkit.md5( input_string => input ))));\n\t\t\t\tend;";
         $backend->execQueryVoid($md5);
         $now = "CREATE OR REPLACE\n\t\t\t\tfunction NOW return DATE as\n\t\t\t\tbegin\n\t\t\t\t\treturn SYSDATE;\n\t\t\t\tend;";
         $backend->execQueryVoid($now);
         $typeStringAgg = "CREATE OR REPLACE TYPE t_string_agg AS OBJECT\n\t\t\t\t\t(\n\t\t\t\t\t  g_string  VARCHAR2(32767),\n\t\t\t\t\t\n\t\t\t\t\t  STATIC FUNCTION ODCIAggregateInitialize(sctx  IN OUT  t_string_agg)\n\t\t\t\t\t\tRETURN NUMBER,\n\t\t\t\t\t\n\t\t\t\t\t  MEMBER FUNCTION ODCIAggregateIterate(self   IN OUT  t_string_agg,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t   value  IN      VARCHAR2 )\n\t\t\t\t\t\t RETURN NUMBER,\n\t\t\t\t\t\n\t\t\t\t\t  MEMBER FUNCTION ODCIAggregateTerminate(self         IN   t_string_agg,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t returnValue  OUT  VARCHAR2,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t flags        IN   NUMBER)\n\t\t\t\t\t\tRETURN NUMBER,\n\t\t\t\t\t\n\t\t\t\t\t  MEMBER FUNCTION ODCIAggregateMerge(self  IN OUT  t_string_agg,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t ctx2  IN      t_string_agg)\n\t\t\t\t\t\tRETURN NUMBER\n\t\t\t\t\t);";
         $backend->execQueryVoid($typeStringAgg);
         $typeStringAgg = "CREATE OR REPLACE TYPE BODY t_string_agg IS\n\t\t\t\t  STATIC FUNCTION ODCIAggregateInitialize(sctx  IN OUT  t_string_agg)\n\t\t\t\t\tRETURN NUMBER IS\n\t\t\t\t  BEGIN\n\t\t\t\t\tsctx := t_string_agg(NULL);\n\t\t\t\t\tRETURN ODCIConst.Success;\n\t\t\t\t  END;\n\n\t\t\t\t  MEMBER FUNCTION ODCIAggregateIterate(self   IN OUT  t_string_agg,\n\t\t\t\t\t\t\t\t\t\t\t\t\t   value  IN      VARCHAR2 )\n\t\t\t\t\tRETURN NUMBER IS\n\t\t\t\t  BEGIN\n\t\t\t\t\tSELF.g_string := self.g_string || ',' || value;\n\t\t\t\t\tRETURN ODCIConst.Success;\n\t\t\t\t  END;\n\n\t\t\t\t  MEMBER FUNCTION ODCIAggregateTerminate(self         IN   t_string_agg,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t returnValue  OUT  VARCHAR2,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t flags        IN   NUMBER)\n\t\t\t\t\tRETURN NUMBER IS\n\t\t\t\t  BEGIN\n\t\t\t\t\treturnValue := RTRIM(LTRIM(SELF.g_string, ','), ',');\n\t\t\t\t\tRETURN ODCIConst.Success;\n\t\t\t\t  END;\n\n\t\t\t\t  MEMBER FUNCTION ODCIAggregateMerge(self  IN OUT  t_string_agg,\n\t\t\t\t\t\t\t\t\t\t\t\t\t ctx2  IN      t_string_agg)\n\t\t\t\t\tRETURN NUMBER IS\n\t\t\t\t  BEGIN\n\t\t\t\t\tSELF.g_string := SELF.g_string || ',' || ctx2.g_string;\n\t\t\t\t\tRETURN ODCIConst.Success;\n\t\t\t\t  END;\n\t\t\t\tEND;";
         $backend->execQueryVoid($typeStringAgg);
         $group_concat = "CREATE OR REPLACE\n\t\t\t\tFUNCTION GROUP_CONCAT (p_input VARCHAR2)\n\t\t\t\tRETURN VARCHAR2\n\t\t\t\tPARALLEL_ENABLE AGGREGATE USING t_string_agg;";
         $backend->execQueryVoid($group_concat);
     }
 }
 /**
  * the constructor
  *
  */
 protected function __construct()
 {
     // setup actions could take quite a while we try to set max execution time to unlimited
     Setup_Core::setExecutionLifeTime(0);
     if (!defined('MAXLOOPCOUNT')) {
         define('MAXLOOPCOUNT', 50);
     }
     $this->_baseDir = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR;
     if (Setup_Core::get(Setup_Core::CHECKDB)) {
         $this->_db = Setup_Core::getDb();
         $this->_backend = Setup_Backend_Factory::factory();
     } else {
         $this->_db = NULL;
     }
     $this->_emailConfigKeys = array('imap' => Tinebase_Config::IMAP, 'smtp' => Tinebase_Config::SMTP, 'sieve' => Tinebase_Config::SIEVE);
 }
 /**
  * create test data in database instance
  *
  * @param Zend_Db_Adapter_Abstract $_db
  */
 protected function _createDbTestTable($_db)
 {
     $setupBackend = Setup_Backend_Factory::factory();
     $setupBackend->dropTable('transactiontest');
     $setupBackend->createTable(new Setup_Backend_Schema_Table_Xml($this->_tableXML));
 }
 protected function setUp()
 {
     $this->_backend = Setup_Backend_Factory::factory();
     $this->_createTestTable();
 }
 /**
  * Initializes database procedures if they exist
  */
 protected function _initProcedures()
 {
     $backend = Setup_Backend_Factory::factory();
     $dbCommand = Tinebase_Backend_Sql_Command::factory(Tinebase_Core::getDb());
     $dbCommand->initProcedures($backend);
 }
 protected function setUp()
 {
     $this->_backend = Setup_Backend_Factory::factory();
 }