Avail feature updated
[ninja.git] / modules / orm / models / objectset.php
bloba8e6a6ab23f7bf5125752199d527c1ab069f1a6c
1 <?php
3 require_once( dirname(__FILE__).'/base/baseobjectset.php' );
5 /**
6 * Describes a set of objects from livestatus
7 */
8 abstract class ObjectSet_Model extends BaseObjectSet_Model {
10 /**
11 * Get statistics about the set, by default only the count
13 public function get_totals() {
14 return array('count' => array($this->get_query(), count($this)));
17 /**
18 * Get the query representing the set
20 public function get_query() {
21 return '['.$this->table.'] '.$this->filter->visit(new LSFilterQueryBuilderVisitor(), 0);
24 /**
25 * Get the first matching object in the set
27 public function one($columns = array()) {
28 if($columns) {
29 $columns = (array) $columns;
31 return $this->it($columns, array(),1,0)->current();
34 /**
35 * FOR TESTING PURPOSE!
37 * Visit filter with an visitor and return the result
39 public function test_visit_filter(LivestatusFilterVisitor $visitor, $data) {
40 return $this->filter->visit($visitor,$data);