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