consturctor just takes an id

This commit is contained in:
Isaac Connor 2015-09-17 15:34:26 -04:00
parent 13327b7651
commit 01718aaffb
1 changed files with 18 additions and 11 deletions

View File

@ -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'};
}
}
?>