Changeset 3961

Show
Ignore:
Timestamp:
05/06/07 03:27:35 (2 years ago)
Author:
diego_iastrubni
Message:

Another merge for sqlite3 support (ticket:1727), as far as I can tell, the code is fully working now.

I added a few comments in the code which will help in the future, and some todo points. Again, as far as I can tell freePBX is fully functional after
this patch.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • freepbx/branches/2.2/amp_conf/htdocs/admin/modules/core/functions.inc.php

    r3960 r3961  
    14261426                // TODO: sqlite work arround - diego  
    14271427                // need to reorder the trunks in PHP code 
    1428                 $unique_trunks = sql("SELECT * FROM globals WHERE variable LIKE 'OUT_%' ORDER BY variable","getAll");  
     1428                // remember, in sqlite3 we need to use escape 
     1429                $unique_trunks = sql("SELECT * FROM globals WHERE variable LIKE 'OUT_\\%' escape '\\' ORDER BY variable","getAll");  
    14291430        } 
    14301431        else 
     
    16431644//get outbound routes for a given trunk 
    16441645function core_trunks_gettrunkroutes($trunknum) { 
    1645         $results = sql("SELECT DISTINCT SUBSTRING(context,7), priority FROM extensions WHERE context LIKE 'outrt-%' AND (args LIKE 'dialout-trunk,".$trunknum.",%' OR args LIKE 'dialout-enum,".$trunknum.",%')ORDER BY context ","getAll"); 
    1646          
     1646        global $amp_conf; 
     1647 
     1648        if ($amp_conf["AMPDBENGINE"] == "sqlite3") 
     1649                $sql_code = "SELECT DISTINCT              context, priority FROM extensions WHERE context LIKE 'outrt-%' AND (args LIKE 'dialout-trunk,".$trunknum.",%' OR args LIKE 'dialout-enum,".$trunknum.",%') ORDER BY context"; 
     1650        else 
     1651                $sql_code = "SELECT DISTINCT SUBSTRING(context,7), priority FROM extensions WHERE context LIKE 'outrt-%' AND (args LIKE 'dialout-trunk,".$trunknum.",%' OR args LIKE 'dialout-enum,".$trunknum.",%') ORDER BY context"; 
     1652 
     1653        $results = sql( $sql_code, "getAll" ); 
     1654 
    16471655        foreach ($results as $row) { 
    1648                 $routes[$row[0]] = $row[1]; 
     1656                // original code was: 
     1657                //      $routes[$row[0]] = $row[1]; 
     1658                // but substring is not supported in sqlite3. 
     1659                // how about we remove the 2nd part of the "if"? and use the same code on all DB's? 
     1660 
     1661                $t = ($amp_conf["AMPDBENGINE"] == "sqlite3") ? substr( $row[0], 7 ) : $row[0]; 
     1662                $r = $row[1]; 
     1663                $routes[ $r ] = $t; 
     1664 
    16491665        } 
    16501666        // array(routename=>priority) 
     
    18251841         
    18261842        $sql = "SELECT DISTINCT SUBSTRING(context,7) FROM extensions WHERE context LIKE 'outrt-%' ORDER BY context "; 
     1843        if ( $amp_conf["AMPDBENGINE"] != "sqlite3") 
     1844                $sql = "SELECT DISTINCT SUBSTRING(context,7) FROM extensions WHERE context LIKE 'outrt-%' ORDER BY context "; 
     1845        else 
     1846                $sql = "SELECT DISTINCT context FROM extensions WHERE context LIKE 'outrt-%' ORDER BY context "; 
     1847 
    18271848        // we SUBSTRING() to remove "outrt-" 
    18281849        $routepriority = $db->getAll($sql); 
     
    18301851                die($routepriority->getMessage()); 
    18311852        } 
     1853 
     1854        // TODO: strip the context on the sqlite3 backend 
     1855        // not sure where does it effects, since this is working on my setup... 
     1856        // welcome to funky town 
    18321857        return ($routepriority); 
    1833          
    18341858} 
    18351859 
Donate



Support
Download
Develop
Forums
News
Documentation
Paid Support
About

Paid Ads