2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-15 03:59:11 +00:00

git-svn-id: https://svn.fhem.de/fhem/trunk@5409 2b470e98-0d58-463d-a4d8-8e2adae1ed80

This commit is contained in:
betateilchen 2014-04-02 04:38:10 +00:00
parent 9dd7f44cdc
commit 68e0c50a5e
2 changed files with 3 additions and 57 deletions

View File

@ -180,34 +180,6 @@ sub CommandConfigdb($$) {
$ret = _cfgDB_Diff($param1, $param2);
}
# when ('export') {
# return "\n Syntax: configdb export <targetFilename> [version]" if @a <2;
# $param2 = $param2 ? $param2 : 0;
# my $logtext = "configDB: database backup started into file $param1";
# $logtext .= " for version $param2";
# Log3 ('configDB', 4, $logtext);
# $ret = _cfgDB_Export($param1, $param2);
# }
#
# when ('import') {
# return "\n Syntax: configdb import <sourceFilename>" if @a != 2;
# open ( FILE, "<./$param1" );
# my @dbconfig = <FILE>;
# my @db2;
# close ( FILE );
# foreach (@dbconfig) {
# my $p = $_;
# my(@p) = split(/\|/,$p,4);
# $p = join(' ',@p);
# $_ = $p;
# }
# $ret = _cfgDB_Execute(undef,@dbconfig);
# $ret .= "\n\n".
# "Import executed into running configuration.\n".
# "Please use <save config> to store\n".
# "this configuration into database!";
# }
when ('info') {
Log3('configdb', 4, "info requested.");
$ret = _cfgDB_Info;

View File

@ -353,11 +353,12 @@ sub _cfgDB_InsertLine($$$) {
# pass command table to AnalyzeCommandChain
sub _cfgDB_Execute($@) {
my ($cl, @dbconfig) = @_;
my $ret;
my ($ret,$r2);
foreach (@dbconfig){
my $l = $_;
$l =~ s/[\r\n]//g;
$ret .= AnalyzeCommandChain($cl, $l);
$r2 = AnalyzeCommandChain($cl, $l);
$ret .= "$r2\n" if($r2);
}
return $ret if($ret);
return undef;
@ -610,33 +611,6 @@ sub _cfgDB_Diff($$) {
return $ret;
}
# backup database
sub _cfgDB_Export($$) {
my ($filename,$version) = @_;
my ($counter, $ret);
my $sql = "select command,device,p1,p2 from fhemconfig".
" as c join fhemversions as v ON v.versionuuid=c.versionuuid ".
"WHERE v.version = '$version' ORDER BY command DESC";
my $fhem_dbh = _cfgDB_Connect;
my $sth=$fhem_dbh->prepare( $sql );
$sth->execute();
open( FILE, ">./$filename" );
while ( my $row = $sth->fetchrow_arrayref ) {
$counter++;
print FILE join( " ", @$row ), "\n";
}
close ( FILE );
$sth->finish();
$fhem_dbh->disconnect();
$ret = "\n $counter records exported ";
$ret .= "from version $version ";
$ret .= "to $filename";
}
1;