Add a find_all function to return an array of Server objects
This commit is contained in:
parent
bfe4175fdf
commit
12ee147bc7
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
require_once( 'database.php' );
|
require_once( 'database.php' );
|
||||||
class Server {
|
class Server {
|
||||||
|
|
||||||
public function __construct( $IdOrRow = NULL ) {
|
public function __construct( $IdOrRow = NULL ) {
|
||||||
$row = NULL;
|
$row = NULL;
|
||||||
if ( $IdOrRow ) {
|
if ( $IdOrRow ) {
|
||||||
|
@ -22,6 +23,15 @@ class Server {
|
||||||
$this->{'Hostname'} = '';
|
$this->{'Hostname'} = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static function find_all() {
|
||||||
|
$servers = array();
|
||||||
|
$result = dbQuery( 'SELECT * FROM Servers ORDER BY Name');
|
||||||
|
$results = $result->fetchALL(PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE, 'Server' );
|
||||||
|
foreach ( $results as $row => $server_obj ) {
|
||||||
|
$servers[] = $server_obj;
|
||||||
|
}
|
||||||
|
return $servers;
|
||||||
|
}
|
||||||
|
|
||||||
public function Url() {
|
public function Url() {
|
||||||
return ZM_BASE_PROTOCOL . '://'. $this->Hostname();
|
return ZM_BASE_PROTOCOL . '://'. $this->Hostname();
|
||||||
|
|
Loading…
Reference in New Issue