root/modules/branches/2.10/setcid/install.php

Revision 11419, 1.1 kB (checked in by mbrevda, 2 years ago)

closes #4606 - allow setcid to support complex expressions. Thanks luxten!

Line 
1 <?php
2
3 global $db;
4
5 $autoincrement = (($amp_conf["AMPDBENGINE"] == "sqlite") || ($amp_conf["AMPDBENGINE"] == "sqlite3")) ? "AUTOINCREMENT":"AUTO_INCREMENT";
6 $sql = "CREATE TABLE IF NOT EXISTS setcid (
7     cid_id INTEGER NOT NULL PRIMARY KEY $autoincrement,
8     cid_name VARCHAR( 255 ) ,
9     cid_num VARCHAR( 255 ) ,
10     description VARCHAR( 50 ) ,
11     dest VARCHAR( 255 )
12 )";
13
14 $check = $db->query($sql);
15 if(DB::IsError($check)) {
16     die_freepbx("Can not create setcid table\n");
17 }
18
19 //migrate name/num to larger size
20 out(_('Migrating Name/Num filed size'));
21 $table = $db->getAssoc('DESCRIBE `setcid`', true, array(), DB_FETCHMODE_ASSOC);
22 $name = str_replace(array('(', ')'), ' ', $table['cid_name']['Type']);
23 $name = explode(' ', $name);
24 if ($name[1] == '50') {
25     $q = $db->query('ALTER TABLE `setcid` CHANGE cid_name cid_name VARCHAR( 255 )');
26     if($db->IsError($q)) {
27         die_freepbx("Can not migrate setcid\n");
28     }
29 }
30
31 $num = str_replace(array('(', ')'), ' ', $table['cid_num']['Type']);
32 $num = explode(' ', $num);
33 if ($num[1] == '50') {
34     $q = $db->query('ALTER TABLE `setcid` CHANGE cid_num cid_num VARCHAR( 255 )');
35     if($db->IsError($q)) {
36         die_freepbx("Can not migrate setcid\n");
37     }
38 }
39 ?>
40
Note: See TracBrowser for help on using the browser.