Created
February 17, 2011 10:14
-
-
Save birkir/831439 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php defined('SYSPATH')or die('No access'); | |
class Controller_Sites extends Controller_Template { | |
public function action_index() | |
{ | |
$sites = ORM::factory('site')->sites()->find_all(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php defined('SYSPATH')or die('No access'); | |
class Model_Site extends ORM { | |
protected $_has_many = array( | |
'servers' => array( | |
'model' => 'server', | |
'far_key' => 'id', | |
'foreign_key' => 'server_id' | |
) | |
); | |
private $server_id = 0; | |
public $ip = '0.0.0.0'; | |
public function factory($model, $id = NULL) | |
{ | |
$this->ip = shell_exec('host $this->name | grep address | awk \'{printf $4}\''); | |
parent::factory($model, $id); | |
} | |
public function sites() | |
{ | |
$this->where('server_id', '=', $this->server_id); | |
return $this; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment