Exemplo n.º 1
0
 /**
  * Returns a reference to the DB object of specific type
  *
  * @param  string $type DB type
  * @param array $config DB configuration
  * @return object DBManager instance
  */
 public static function getTypeInstance($type, $config = array())
 {
     global $sugar_config;
     if (empty($config['db_manager'])) {
         // standard types
         switch ($type) {
             case "mysql":
                 if (empty($sugar_config['mysqli_disabled']) && function_exists('mysqli_connect')) {
                     $my_db_manager = 'MysqliManager';
                 } else {
                     $my_db_manager = "MysqlManager";
                 }
                 break;
             case "mssql":
                 if (function_exists('sqlsrv_connect') && (empty($config['db_mssql_force_driver']) || $config['db_mssql_force_driver'] == 'sqlsrv')) {
                     $my_db_manager = 'SqlsrvManager';
                 } elseif (self::isFreeTDS() && (empty($config['db_mssql_force_driver']) || $config['db_mssql_force_driver'] == 'freetds')) {
                     $my_db_manager = 'FreeTDSManager';
                 } else {
                     $my_db_manager = 'MssqlManager';
                 }
                 break;
             default:
                 $my_db_manager = self::getManagerByType($type, false);
                 if (empty($my_db_manager)) {
                     echo $type . "\n";
                     display_stack_trace();
                     $GLOBALS['log']->fatal("unable to load DB manager for: {$type}");
                     sugar_die("Cannot load DB manager");
                 }
         }
     } else {
         $my_db_manager = $config['db_manager'];
     }
     // sanitize the name
     $my_db_manager = preg_replace("/[^A-Za-z0-9_-]/", "", $my_db_manager);
     if (!empty($config['db_manager_class'])) {
         $my_db_manager = $config['db_manager_class'];
     } else {
         SugarAutoLoader::requireWithCustom("include/database/{$my_db_manager}.php");
     }
     if (class_exists($my_db_manager)) {
         return new $my_db_manager();
     } else {
         return null;
     }
 }
Exemplo n.º 2
0
function StackTraceErrorHandler($errno, $errstr, $errfile, $errline, $errcontext)
{
    $error_msg = " {$errstr} occured in <b>{$errfile}</b> on line {$errline} [" . date("Y-m-d H:i:s") . ']';
    $halt_script = true;
    switch ($errno) {
        case 2048:
            return;
            //depricated we have lots of these ignore them
        //depricated we have lots of these ignore them
        case E_USER_NOTICE:
        case E_NOTICE:
            if (error_reporting() & E_NOTICE) {
                $halt_script = false;
                $type = 'Notice';
            } else {
                return;
            }
            break;
        case E_USER_WARNING:
        case E_COMPILE_WARNING:
        case E_CORE_WARNING:
        case E_WARNING:
            $halt_script = false;
            $type = "Warning";
            break;
        case E_USER_ERROR:
        case E_COMPILE_ERROR:
        case E_CORE_ERROR:
        case E_ERROR:
            $type = "Fatal Error";
            break;
        case E_PARSE:
            $type = "Parse Error";
            break;
        default:
            //don't know what it is might not be so bad
            $halt_script = false;
            $type = "Unknown Error ({$errno})";
            break;
    }
    $error_msg = '<b>' . $type . '</b>:' . $error_msg;
    echo $error_msg;
    display_stack_trace();
    if ($halt_script) {
        exit - 1;
    }
}
Exemplo n.º 3
0
 function getSearchViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex)
 {
     display_stack_trace();
     $this->getEditViewSmarty($parentFieldArray, $vardef, $displayParams, $tabindex, true);
 }
Exemplo n.º 4
0
/**
 * Private helper function for displaying the contents of a given variable.
 * This function is only intended to be used for internal development.
 * The pp stands for Pre Print Trace Die.
 */
function _pptd($mixed)
{
    echo "\n<pre>\n";
    print_r($mixed);
    echo "\n</pre>\n";
    display_stack_trace();
    die;
}