Example #1
0
/**
 * Returns the SQL code used for concatenating strings
 *
 * @access public
 * @param  string   Input string/column to concatenate
 * @return string   SQL parameter
 */
function serendipity_db_concat($string)
{
    global $serendipity;
    $type_of_database = sqlrcon_identify($serendipity['dbConn']);
    switch ($type_of_database) {
        case 'mysql':
            return 'concat(' . $string . ')';
        case 'postgresql':
            return '(' . str_replace(', ', '||', $string) . ')';
        case 'sqlite':
            return 'concat(' . $string . ')';
        default:
            return 'concat(' . $string . ')';
    }
}
 /**
  * Non-persistent database connection
  * 
  * @access	protected
  * @return	resource
  * @see     parent::initialize();
  */
 function db_connect()
 {
     if (!function_exists('sqlrcon_alloc')) {
         log_message('error', 'Driver Db_sqlrelay ' . "\t" . 'Method db_connect ' . PHP_EOL . "\t\t" . 'Module SQL Relay non chargé dans la configuration serveur"' . PHP_EOL . " Connexion data " . PHP_EOL . " username : "******" hostname : " . $this->hostname . PHP_EOL . " database : " . $this->database . PHP_EOL . " dbdriver : " . $this->dbdriver . PHP_EOL . " dbprefix : " . $this->dbprefix . PHP_EOL . " port     : " . $this->port);
         return false;
     }
     $sConnect = sqlrcon_alloc($this->hostname, $this->port, '', $this->username, $this->password, 1, 3);
     if (sqlrcon_ping($sConnect) !== 1) {
         log_message('error', 'Driver Db_sqlrelay ' . "\t" . 'Method db_connect ' . PHP_EOL . "\t\t" . 'Pas de ping serveur"' . PHP_EOL . " Connexion data " . PHP_EOL . " username : "******" hostname : " . $this->hostname . PHP_EOL . " database : " . $this->database . PHP_EOL . " dbdriver : " . $this->dbdriver . PHP_EOL . " dbprefix : " . $this->dbprefix . PHP_EOL . " port     : " . $this->port);
         return false;
     }
     if (sqlrcon_identify($sConnect) == 'oracle8') {
         $this->setIsOracle(true);
         $this->setPrefetchState(true);
     } else {
         $this->setIsOracle(false);
     }
     //         $curs_id = sqlrcur_alloc($sConnect);
     //         sqlrcur_prepareQuery($curs_id, "ALTER SESSION SET NLS_NUMERIC_CHARACTERS = '. ' ");
     //         sqlrcur_sendquery($curs_id, "ALTER SESSION SET NLS_NUMERIC_CHARACTERS = '. ' ");
     //         sqlrcur_free($curs_id);
     return $sConnect;
 }