mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-11-30 17:20:32 +01:00
2018-06-01 Fred Gleason <fredg@paravelsystems.com>
* Stubbed out rddbmgr(8). * Implemented the '--create' command in rddbmgr(8). * Fixed a bug in 'RDStation::create()' that generated corrupt records in the 'AUDIO_INPUT' and 'AUDIO_OUTPUTS' tables when creating a new host with no exemplar.
This commit is contained in:
@@ -587,9 +587,14 @@ void RDConfig::load()
|
||||
profile->stringValue("mySQL","Charset",DEFAULT_MYSQL_CHARSET);
|
||||
conf_mysql_collation=
|
||||
profile->stringValue("mySQL","Collation",DEFAULT_MYSQL_COLLATION);
|
||||
/*
|
||||
conf_create_table_postfix=QString(" engine ")+conf_mysql_engine+" "+
|
||||
"character set "+conf_mysql_charset+" "+
|
||||
"collate "+conf_mysql_collation;
|
||||
*/
|
||||
conf_create_table_postfix=
|
||||
RDConfig::createTablePostfix(conf_mysql_engine,conf_mysql_charset,
|
||||
conf_mysql_collation);
|
||||
|
||||
facility=profile->stringValue("Logs","Facility",DEFAULT_LOG_FACILITY).lower();
|
||||
if(facility=="syslog") {
|
||||
@@ -759,3 +764,12 @@ QString RDConfig::userAgent(const QString &modname)
|
||||
}
|
||||
return QString("Mozilla/5.0 rivendell/")+VERSION+" ("+modname+")";
|
||||
}
|
||||
|
||||
|
||||
QString RDConfig::createTablePostfix(const QString &engine,
|
||||
const QString &charset,
|
||||
const QString &collation)
|
||||
{
|
||||
return QString(" engine ")+engine+" "+"character set "+charset+" "+
|
||||
"collate "+collation;
|
||||
}
|
||||
|
||||
@@ -119,6 +119,9 @@ class RDConfig
|
||||
void load();
|
||||
void clear();
|
||||
static QString userAgent(const QString &modname);
|
||||
static QString createTablePostfix(const QString &engine,
|
||||
const QString &charset,
|
||||
const QString &collation);
|
||||
|
||||
private:
|
||||
QString conf_filename;
|
||||
|
||||
32
lib/rddb.cpp
32
lib/rddb.cpp
@@ -120,6 +120,38 @@ RDSqlQuery::RDSqlQuery(const QString &query,bool reconnect):
|
||||
}
|
||||
|
||||
|
||||
QVariant RDSqlQuery::run(const QString &sql,bool *ok)
|
||||
{
|
||||
QVariant ret;
|
||||
|
||||
RDSqlQuery *q=new RDSqlQuery(sql);
|
||||
if(ok!=NULL) {
|
||||
*ok=q->isActive();
|
||||
}
|
||||
delete q;
|
||||
|
||||
q=new RDSqlQuery("select LAST_INSERT_ID()",false);
|
||||
if(q->first()) {
|
||||
ret=q->value(0);
|
||||
}
|
||||
delete q;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int RDSqlQuery::rows(const QString &sql)
|
||||
{
|
||||
int ret=0;
|
||||
|
||||
RDSqlQuery *q=new RDSqlQuery(sql);
|
||||
ret=q->size();
|
||||
delete q;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void RDSqlDatabaseStatus::sendRecon()
|
||||
{
|
||||
if (discon){
|
||||
|
||||
@@ -49,6 +49,8 @@ class RDSqlQuery : public QSqlQuery
|
||||
{
|
||||
public:
|
||||
RDSqlQuery(const QString &query=QString::null,bool reconnect=true);
|
||||
static QVariant run(const QString &sql,bool *ok=NULL);
|
||||
static int rows(const QString &sql);
|
||||
};
|
||||
|
||||
// Setup the default database, returns true on success.
|
||||
|
||||
@@ -736,14 +736,14 @@ bool RDStation::create(const QString &name,QString *err_msg,
|
||||
sql=QString("insert into AUDIO_INPUTS set ")+
|
||||
"STATION_NAME=\""+RDEscapeString(name)+"\","+
|
||||
QString().sprintf("CARD_NUMBER=%d,",i)+
|
||||
QString().sprintf("PORT_NUMBER=%d",i);
|
||||
QString().sprintf("PORT_NUMBER=%d",j);
|
||||
q=new RDSqlQuery(sql);
|
||||
delete q;
|
||||
|
||||
sql=QString("insert into AUDIO_OUTPUTS set ")+
|
||||
"STATION_NAME=\""+RDEscapeString(name)+"\","+
|
||||
QString().sprintf("CARD_NUMBER=%d,",i)+
|
||||
QString().sprintf("PORT_NUMBER=%d",i);
|
||||
QString().sprintf("PORT_NUMBER=%d",j);
|
||||
q=new RDSqlQuery(sql);
|
||||
delete q;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user