Reputation: 5208
i have two values. one represents a number of objects
$a = $product->count_all();
and the other represents a value from the database:
$first = Model::factory('product')->sale($sale_id)->find();
i need the sum between the two. the second returns the first id that satsfies the query conditions. how can i convert the $first variable to int in kohana or how can i make this sum?? thank you!
Upvotes: 0
Views: 411
Reputation: 5483
Use $_ignored_columns
for it:
protected $_ignored_columns = array('count');
So, you can initialize it
($first->count = $a;
) and get as a
model column ($count =
$first->count;
).
Create special method get_count()
in your
model:
protected $_row_count; public function get_count() { if ( $this->_row_count === NULL) { $this->_row_count = ORM::factory($this->_object_name)->count_all(); } return $this->_row_count; }
Upvotes: 1