cleanup
This commit is contained in:
parent
b445ddc981
commit
1ef5226316
|
@ -24,7 +24,6 @@
|
|||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
Group::Group() {
|
||||
Warning("Instantiating default Group Object. Should not happen.");
|
||||
|
@ -33,30 +32,31 @@ Group::Group() {
|
|||
strcpy(name, "Default");
|
||||
}
|
||||
|
||||
Group::Group( MYSQL_ROW &dbrow ) {
|
||||
// The order of columns is: Id, ParentId, Name
|
||||
Group::Group(MYSQL_ROW &dbrow) {
|
||||
unsigned int index = 0;
|
||||
id = atoi( dbrow[index++] );
|
||||
parent_id = dbrow[index] ? atoi( dbrow[index] ): 0; index++;
|
||||
strncpy( name, dbrow[index++], sizeof(name)-1 );
|
||||
id = atoi(dbrow[index++]);
|
||||
parent_id = dbrow[index] ? atoi(dbrow[index]): 0; index++;
|
||||
strncpy(name, dbrow[index++], sizeof(name)-1);
|
||||
}
|
||||
|
||||
/* If a zero or invalid p_id is passed, then the old default path will be assumed. */
|
||||
Group::Group( unsigned int p_id ) {
|
||||
Group::Group(unsigned int p_id) {
|
||||
id = 0;
|
||||
|
||||
if ( p_id ) {
|
||||
char sql[ZM_SQL_SML_BUFSIZ];
|
||||
snprintf( sql, sizeof(sql), "SELECT Id, ParentId, Name FROM Group WHERE Id=%d", p_id );
|
||||
Debug(2,"Loading Group for %d using %s", p_id, sql );
|
||||
snprintf(sql, sizeof(sql), "SELECT Id, ParentId, Name FROM Group WHERE Id=%d", p_id);
|
||||
Debug(2,"Loading Group for %d using %s", p_id, sql);
|
||||
zmDbRow dbrow;
|
||||
if ( ! dbrow.fetch( sql ) ) {
|
||||
Error( "Unable to load group for id %d: %s", p_id, mysql_error( &dbconn ) );
|
||||
if ( !dbrow.fetch(sql) ) {
|
||||
Error("Unable to load group for id %d: %s", p_id, mysql_error(&dbconn));
|
||||
} else {
|
||||
unsigned int index = 0;
|
||||
id = atoi( dbrow[index++] );
|
||||
parent_id = dbrow[index] ? atoi( dbrow[index] ): 0; index++;
|
||||
strncpy( name, dbrow[index++], sizeof(name)-1 );
|
||||
Debug( 1, "Loaded Group area %d '%s'", id, this->Name() );
|
||||
id = atoi(dbrow[index++]);
|
||||
parent_id = dbrow[index] ? atoi(dbrow[index]): 0; index++;
|
||||
strncpy(name, dbrow[index++], sizeof(name)-1);
|
||||
Debug(1, "Loaded Group area %d '%s'", id, this->Name());
|
||||
}
|
||||
}
|
||||
if ( ! id ) {
|
||||
|
|
Loading…
Reference in New Issue