consturctor just takes an id
This commit is contained in:
parent
13327b7651
commit
01718aaffb
|
@ -1,20 +1,27 @@
|
||||||
<?php
|
<?php
|
||||||
require_once( 'database.php' );
|
require_once( 'database.php' );
|
||||||
class Server {
|
class Server {
|
||||||
public function __construct( array $params = array() ) {
|
public function __construct( $id ) {
|
||||||
if ( isset( $params['Id']) and $params['Id'] ) {
|
if ( $id ) {
|
||||||
$s = dbFetchOne( 'SELECT * FROM Servers WHERE Id=?', NULL, array( $params['Id'] ) );
|
$s = dbFetchOne( 'SELECT * FROM Servers WHERE Id=?', NULL, array( $id ) );
|
||||||
if ( $s ) {
|
if ( $s ) {
|
||||||
foreach ($s as $k => $v) {
|
foreach ($s as $k => $v) {
|
||||||
$this->{$k} = $v;
|
$this->{$k} = $v;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Error("Unable to load Server record for Id=" . $params['Id'] );
|
Error("Unable to load Server record for Id=" . $id );
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$this->{'Name'} = '';
|
||||||
|
$this->{'Hostname'} = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function Name() {
|
public function Name() {
|
||||||
return $this->{'Name'};
|
return $this->{'Name'};
|
||||||
}
|
}
|
||||||
|
public function Hostname() {
|
||||||
|
return $this->{'Hostname'};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in New Issue