Skip to content

Instantly share code, notes, and snippets.

@birkir
Created February 17, 2011 10:14
Show Gist options
  • Save birkir/831439 to your computer and use it in GitHub Desktop.
Save birkir/831439 to your computer and use it in GitHub Desktop.
<?php defined('SYSPATH')or die('No access');
class Controller_Sites extends Controller_Template {
public function action_index()
{
$sites = ORM::factory('site')->sites()->find_all();
}
}
<?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