No postgre support, install file improvement.
ardas - October 16, 2006 - 17:22
| Project: | SMS Gateway |
| Version: | 4.7.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
Greetings,
First of all thanks a lot for smsgateway.module. I have found that there is no PostgreSQL support and MySQL installation is not included into install file. I propose you the following source code to add PostgreSQL support and move MySQL installation (to get rid of smsgateway.mysql script).
<?php
function smsgateway_install()
{
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret1 = db_query('
CREATE TABLE {smslog} (
sid int(10) NOT NULL auto_increment,
direction varchar(3) NOT NULL,
number varchar(20) NOT NULL,
message text default NULL,
response varchar(128) default NULL,
`timestamp` int(11) unsigned NOT NULL default 0,
KEY smslog_timestamp (timestamp),
PRIMARY KEY (sid)) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;
');
$ret2 = $ret1;
break;
case 'pgsql':
$ret1 = db_query('
CREATE TABLE {smslog} (
sid serial NOT NULL,
direction varchar(3) NOT NULL,
number varchar(20) NOT NULL,
message text default NULL,
response varchar(128) default NULL,
timestamp integer NOT NULL default 0,
PRIMARY KEY (sid));
');
$ret2 = db_query('CREATE INDEX smslog_timestamp ON {smslog} (timestamp);');
break;
}
if ($ret1 && $ret2) {
drupal_set_message(t('SMS Gateway module installed succesfully.'));
} else {
drupal_set_message(t('SMS Gateway module installation was unsuccesfull. Necessary database tables should be created by hand.', 'error'));
}
}
function smsgateway_update_1() {
return _system_update_utf8( array('smslog'));
}
?>Please, consider using this code for install file for both CVS version and 4.7 branch.
Thanks a lot.

#1
Hi Duke,
Many thanks - I only recently became aware of the install file's potential, but hadn't had a chance to implement it. Thanks also for the PostgreSQL addition, which is really valuable. The change should be in the tarballs in the morning.
Note that I have tested the MyQSL installation, but not the PostgreSQL, so please report any issues.
Thanks
David
#2
No problems :)
This is a power of community. I myself am very new to Postgre, but I need to use it in my project, so I began to test all necessary modules for PostgreSQL compatibility.
#3