/** * Generated a find_by_slug method for Jam_Builder * @param Jam_Builder $builder the builder object * @param string $slug the slug to search for * @param Jam_Event_Data $data * @return void */ public function builder_call_where_slug(Jam_Query_Builder_Select $builder, Jam_Event_Data $data, $slug) { if (preg_match($this->_pattern, $slug, $matches)) { $builder->where($this->_uses_primary_key ? ':primary_key' : 'slug', '=', $matches[$this->_uses_primary_key ? 2 : 0]); } else { throw new Kohana_Exception("Invalid Slug :slug for :model", array(':slug' => $slug, ':model' => $builder->meta()->model())); } }
public function builder_before_select(Jam_Query_Builder_Select $select) { if (!$select->order_by) { $select->order_by_position(); } }
/** * @dataProvider data_except */ public function test_except($except, $expected_sql) { $select = new Jam_Query_Builder_Select('test_post'); $select->join('test_author')->where('name', '=', 'Adam')->order_by('id', 'DESC'); if ($expected_sql === NULL) { $this->setExpectedException('Kohana_Exception'); } call_user_func_array(array($select, 'except'), $except); $this->assertEquals($expected_sql, (string) $select); }
/** * Generate a where_token method for Jam_Query_Builder_Select * @param Jam_Query_Builder_Select $builder the builder object * @param Jam_Event_Data $data * @param string $token the token to search for * @return void */ public function builder_call_where_token(Jam_Query_Builder_Select $builder, Jam_Event_Data $data, $token) { $builder->where($this->_model . '.' . $this->_field, '=', $token); }