Rob
Active Member
Hi
I'm creating an extension and need to create DB tables. I looked at the Support Ticket extension and looked at how that was doing it.
I created a folder & files /common/data/sql/install.sql * delete.sql using the ones from Support Ticket and entered my table details.
I then added the following to my SmsExt.php file:
When I try to install the extension I receive this error:
Parse error: syntax error, unexpected 'protected' (T_PROTECTED) in /var/www/html/apps/extensions/sms/SmsExt.php on line 145
What else do I need to add to the extension to get it to add tables?
Thanks
Rob
I'm creating an extension and need to create DB tables. I looked at the Support Ticket extension and looked at how that was doing it.
I created a folder & files /common/data/sql/install.sql * delete.sql using the ones from Support Ticket and entered my table details.
I then added the following to my SmsExt.php file:
Code:
protected function runQueriesFromSqlFile($fileName)
{
if (!is_file($sqlFile = dirname(__FILE__) . sprintf('/common/data/sql/%s.sql', $fileName))) {
return false;
}
$queries = (array)CommonHelper::getQueriesFromSqlFile($sqlFile, Yii::app()->getDb()->tablePrefix);
foreach ($queries as $query) {
Yii::app()->getDb()->createCommand($query)->execute();
}
return true;
}
When I try to install the extension I receive this error:
Parse error: syntax error, unexpected 'protected' (T_PROTECTED) in /var/www/html/apps/extensions/sms/SmsExt.php on line 145
What else do I need to add to the extension to get it to add tables?
Thanks
Rob