Changeset 3961
- Timestamp:
- 05/06/07 03:27:35 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
freepbx/branches/2.2/amp_conf/htdocs/admin/modules/core/functions.inc.php
r3960 r3961 1426 1426 // TODO: sqlite work arround - diego 1427 1427 // 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"); 1429 1430 } 1430 1431 else … … 1643 1644 //get outbound routes for a given trunk 1644 1645 function 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 1647 1655 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 1649 1665 } 1650 1666 // array(routename=>priority) … … 1825 1841 1826 1842 $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 1827 1848 // we SUBSTRING() to remove "outrt-" 1828 1849 $routepriority = $db->getAll($sql); … … 1830 1851 die($routepriority->getMessage()); 1831 1852 } 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 1832 1857 return ($routepriority); 1833 1834 1858 } 1835 1859
