本文整理汇总了PHP中Model_Ad::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Model_Ad::where方法的具体用法?PHP Model_Ad::where怎么用?PHP Model_Ad::where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model_Ad
的用法示例。
在下文中一共展示了Model_Ad::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_index
public function action_index()
{
$this->auto_render = FALSE;
$info = array('title' => 'RSS ' . htmlspecialchars(Core::config('general.site_name')), 'pubDate' => date("r"), 'description' => __('Latest published'), 'generator' => 'Open Classifieds');
$items = array();
//last ads, you can modify this value at: advertisement.feed_elements
$ads = new Model_Ad();
$ads->where('status', '=', Model_Ad::STATUS_PUBLISHED)->order_by('published', 'desc')->limit(Core::config('advertisement.feed_elements'));
//filter by category aor location
if (Model_Category::current()->loaded()) {
$ads->where('id_category', '=', Model_Category::current()->id_category);
}
if (Model_Location::current()->loaded()) {
$ads->where('id_location', '=', Model_Location::current()->id_location);
}
$ads = $ads->cached()->find_all();
foreach ($ads as $a) {
$url = Route::url('ad', array('category' => $a->category->seoname, 'seotitle' => $a->seotitle));
$item = array('title' => htmlspecialchars($a->title, ENT_QUOTES), 'link' => $url, 'pubDate' => Date::mysql2unix($a->published), 'description' => htmlspecialchars(Text::removebbcode($a->description), ENT_QUOTES), 'guid' => $url);
if ($a->get_first_image() !== NULL) {
$item['description'] = '<img src="' . $a->get_first_image() . '" />' . $item['description'];
}
$items[] = $item;
}
$xml = Feed::create($info, $items);
$this->response->headers('Content-type', 'text/xml');
$this->response->body($xml);
}
示例2: before
/**
* Automatically executed before the widget action. Can be used to set
* class properties, do authorization checks, and execute other custom code.
*
* @return void
*/
public function before()
{
$ads = new Model_Ad();
$ads->where('status', '=', Model_Ad::STATUS_PUBLISHED);
//if ad have passed expiration time dont show
if (core::config('advertisement.expire_date') > 0) {
$ads->where(DB::expr('DATE_ADD( published, INTERVAL ' . core::config('advertisement.expire_date') . ' DAY)'), '>', Date::unix2mysql());
}
switch ($this->ads_type) {
case 'popular':
$id_ads = array_keys(Model_Visit::popular_ads());
if (count($id_ads) > 0) {
$ads->where('id_ad', 'IN', $id_ads);
}
break;
case 'featured':
$ads->where('featured', 'IS NOT', NULL)->where('featured', '>', Date::unix2mysql())->order_by('featured', 'desc');
break;
case 'latest':
default:
$ads->order_by('published', 'desc');
break;
}
$ads = $ads->limit($this->ads_limit)->cached()->find_all();
//die(print_r($ads));
$this->ads = $ads;
}
示例3: action_index
public function action_index()
{
//template header
$this->template->title = '';
// $this->template->meta_keywords = 'keywords';
$this->template->meta_description = Core::config('general.site_description');
//setting main view/template and render pages
// swith to decide on ads_in_home
$ads = new Model_Ad();
$ads->where('status', '=', Model_Ad::STATUS_PUBLISHED);
switch (core::config('advertisement.ads_in_home')) {
case 2:
$id_ads = array_keys(Model_Visit::popular_ads());
if (count($id_ads) > 0) {
$ads->where('id_ad', 'IN', $id_ads);
}
break;
case 1:
$ads->where('featured', 'IS NOT', NULL)->where('featured', 'BETWEEN', array(DB::expr('NOW()'), Date::unix2mysql(time() + core::config('payment.featured_days') * 24 * 60 * 60)))->order_by('featured', 'desc');
break;
case 0:
default:
$ads->order_by('published', 'desc');
break;
}
//if ad have passed expiration time dont show
if (core::config('advertisement.expire_date') > 0) {
$ads->where(DB::expr('DATE_ADD( published, INTERVAL ' . core::config('advertisement.expire_date') . ' DAY)'), '>', DB::expr('NOW()'));
}
$ads = $ads->limit(Theme::get('num_home_latest_ads', 4))->cached()->find_all();
$this->ads = $ads;
$categs = Model_Category::get_category_count();
$this->template->bind('content', $content);
$this->template->content = View::factory('pages/home', array('ads' => $ads, 'categs' => $categs));
}
示例4: before
/**
* Automatically executed before the widget action. Can be used to set
* class properties, do authorization checks, and execute other custom code.
*
* @return void
*/
public function before()
{
$ads = new Model_Ad();
$ads->where('status', '=', Model_Ad::STATUS_PUBLISHED);
$ads->where('featured', 'IS NOT', NULL)->where('featured', 'BETWEEN', array(DB::expr('NOW()'), Date::unix2mysql(time() + core::config('payment.featured_days') * 24 * 60 * 60)))->order_by('featured', 'desc');
$ads = $ads->limit($this->ads_limit)->cached()->find_all();
$this->ads = $ads;
}
示例5: before
/**
* Automatically executed before the widget action. Can be used to set
* class properties, do authorization checks, and execute other custom code.
*
* @return void
*/
public function before()
{
$ads = new Model_Ad();
$ads->where('status', '=', Model_Ad::STATUS_PUBLISHED);
$ads->where('featured', 'IS NOT', NULL)->where('featured', '>', Date::unix2mysql())->order_by('featured', 'desc');
$ads = $ads->limit($this->ads_limit)->find_all();
$this->ads = $ads;
}
示例6: action_index
public function action_index()
{
if (core::config('general.auto_locate')) {
Theme::$scripts['footer'][] = '//maps.google.com/maps/api/js?sensor=false&libraries=geometry&v=3.7';
Theme::$scripts['footer'][] = '//cdn.jsdelivr.net/gmaps/0.4.15/gmaps.min.js';
}
//template header
$this->template->title = '';
// $this->template->meta_keywords = 'keywords';
if (core::config('general.site_description') != '') {
$this->template->meta_description = core::config('general.site_description');
} else {
$this->template->meta_description = core::config('general.site_name') . ' ' . __('official homepage, get your post listed now.');
}
//setting main view/template and render pages
// swith to decide on ads_in_home
$ads = new Model_Ad();
$ads->where('status', '=', Model_Ad::STATUS_PUBLISHED);
$ads_in_home = core::config('advertisement.ads_in_home');
//in case we do not count visits we cant show popular
if (core::config('advertisement.count_visits') == 0 and $ads_in_home == 2) {
$ads_in_home = 0;
}
switch ($ads_in_home) {
case 2:
$id_ads = array_keys(Model_Visit::popular_ads());
if (count($id_ads) > 0) {
$ads->where('id_ad', 'IN', $id_ads);
}
break;
case 1:
$ads->where('featured', 'IS NOT', NULL)->where('featured', '>=', Date::unix2mysql())->order_by('featured', 'desc');
break;
case 4:
$ads->where('featured', 'IS NOT', NULL)->where('featured', '>=', Date::unix2mysql())->order_by(DB::expr('RAND()'));
break;
case 0:
default:
$ads->order_by('published', 'desc');
break;
}
//if ad have passed expiration time dont show
if (core::config('advertisement.expire_date') > 0) {
$ads->where(DB::expr('DATE_ADD( published, INTERVAL ' . core::config('advertisement.expire_date') . ' DAY)'), '>', Date::unix2mysql());
}
$ads = $ads->limit(Theme::get('num_home_latest_ads', 4))->cached()->find_all();
$categs = Model_Category::get_category_count();
$locats = Model_Location::get_location_count();
$auto_locats = NULL;
if (core::config('general.auto_locate') and Model_User::get_userlatlng()) {
$auto_locats = new Model_Location();
$auto_locats = $auto_locats->select(array(DB::expr('degrees(acos(sin(radians(' . $_COOKIE['mylat'] . ')) * sin(radians(`latitude`)) + cos(radians(' . $_COOKIE['mylat'] . ')) * cos(radians(`latitude`)) * cos(radians(abs(' . $_COOKIE['mylng'] . ' - `longitude`))))) * 111.321'), 'distance'))->where('latitude', 'IS NOT', NULL)->where('longitude', 'IS NOT', NULL)->having('distance', '<=', '100')->order_by('distance', 'desc')->find_all()->as_array();
}
$this->template->bind('content', $content);
$this->template->content = View::factory('pages/home', array('ads' => $ads, 'categs' => $categs, 'locats' => $locats, 'auto_locats' => $auto_locats));
}
示例7: current
/**
* returns the current ad
* @return Model_Ad
*/
public static function current()
{
//we don't have so let's retrieve
if (self::$_current === NULL) {
self::$_current = new self();
if (strtolower(Request::current()->controller() == 'Ad') and strtolower(Request::current()->action()) == 'view' and Request::current()->param('seotitle') !== NULL) {
self::$_current = self::$_current->where('seotitle', '=', Request::current()->param('seotitle'))->limit(1)->cached()->find();
}
}
return self::$_current;
}
示例8: action_get
public function action_get()
{
try {
if (is_numeric($id_ad = $this->request->param('id'))) {
$ad = new Model_Ad();
//get distance to the ad
if (isset($this->_params['latitude']) and isset($this->_params['longitude'])) {
$ad->select(array(DB::expr('degrees(acos(sin(radians(' . $this->_params['latitude'] . ')) * sin(radians(`latitude`)) + cos(radians(' . $this->_params['latitude'] . ')) * cos(radians(`latitude`)) * cos(radians(abs(' . $this->_params['longitude'] . ' - `longitude`))))) * 69.172'), 'distance'));
}
$ad->where('id_ad', '=', $id_ad)->where('status', '=', Model_Ad::STATUS_PUBLISHED)->cached()->find();
if ($ad->loaded()) {
$a = $ad->as_array();
$a['price'] = i18n::money_format($ad->price);
$a['images'] = array_values($ad->get_images());
$a['category'] = $ad->category->as_array();
$a['location'] = $ad->location->as_array();
$a['user'] = Controller_Api_Users::get_user_array($ad->user);
$a['customfields'] = Model_Field::get_by_category($ad->id_category);
//sorting by distance, lets add it!
if (isset($ad->distance)) {
$a['distance'] = i18n::format_measurement($ad->distance);
}
$a['url'] = Route::url('ad', array('category' => $ad->category->seoname, 'seotitle' => $ad->seotitle));
$this->rest_output(array('ad' => $a));
} else {
$this->_error(__('Advertisement not found'), 404);
}
} else {
$this->_error(__('Advertisement not found'), 404);
}
} catch (Kohana_HTTP_Exception $khe) {
$this->_error($khe);
return;
}
}
示例9: action_moderate
/**
* Action MODERATION
*/
public function action_moderate()
{
//template header
$this->template->title = __('Moderation');
$this->template->meta_description = __('Moderation');
$this->template->scripts['footer'][] = '/js/oc-panel/moderation.js';
//find all tables
$ads = new Model_Ad();
$res_count = $ads->where('status', '=', Model_Ad::STATUS_NOPUBLISHED)->count_all();
if ($res_count > 0) {
$pagination = Pagination::factory(array('view' => 'pagination', 'total_items' => $res_count, 'items_per_page' => core::config('general.advertisements_per_page')))->route_params(array('controller' => $this->request->controller(), 'action' => $this->request->action()));
$ads = $ads->where('ad.status', '=', Model_Ad::STATUS_NOPUBLISHED)->order_by('created', 'desc')->limit($pagination->items_per_page)->offset($pagination->offset)->find_all();
//find all tables
$hits = new Model_Visit();
$hits->find_all();
$list_cat = Model_Category::get_all();
$list_loc = Model_Location::get_all();
$arr_hits = array();
// array of hit integers
// fill array with hit integers
foreach ($ads as $key_ads) {
// match hits with ad
$h = $hits->where('id_ad', '=', $key_ads->id_ad);
$count = count($h->find_all());
// count individual hits
array_push($arr_hits, $count);
}
$this->template->content = View::factory('oc-panel/pages/moderate', array('ads' => $ads, 'pagination' => $pagination, 'category' => $list_cat, 'location' => $list_loc, 'hits' => $arr_hits));
// create view, and insert list with data
} else {
Alert::set(Alert::INFO, __('You do not have any advertisements waiting to be published'));
$this->template->content = View::factory('oc-panel/pages/moderate', array('ads' => NULL));
}
}
示例10: action_profile
public function action_profile()
{
$this->auto_render = FALSE;
$xml = 'FALSE';
$seoname = $this->request->param('seoname', NULL);
if ($seoname !== NULL) {
$user = new Model_User();
$user->where('seoname', '=', $seoname)->where('status', '=', Model_User::STATUS_ACTIVE)->limit(1)->cached()->find();
if ($user->loaded()) {
$info = array('title' => 'RSS ' . $user->name, 'pubDate' => date("r"), 'description' => $user->name . ' - ' . $user->description, 'generator' => 'Open Classifieds');
$items = array();
//last ads, you can modify this value at: advertisement.feed_elements
$ads = new Model_Ad();
$ads->where('status', '=', Model_Ad::STATUS_PUBLISHED)->where('id_user', '=', $user->id_user)->order_by('published', 'desc')->limit(Core::config('advertisement.feed_elements'));
$ads = $ads->cached()->find_all();
foreach ($ads as $a) {
$url = Route::url('ad', array('category' => $a->category->seoname, 'seotitle' => $a->seotitle));
$item = array('title' => htmlspecialchars($a->title, ENT_QUOTES), 'link' => $url, 'pubDate' => Date::mysql2unix($a->published), 'description' => htmlspecialchars(Text::removebbcode($a->description), ENT_QUOTES), 'guid' => $url);
if ($a->get_first_image() !== NULL) {
$item['description'] = '<img src="' . $a->get_first_image() . '" />' . $item['description'];
}
$items[] = $item;
}
$xml = Feed::create($info, $items);
}
}
$this->response->headers('Content-type', 'text/xml');
$this->response->body($xml);
}
示例11: before
/**
* Automatically executed before the widget action. Can be used to set
* class properties, do authorization checks, and execute other custom code.
*
* @return void
*/
public function before()
{
$ad = new Model_Ad();
$ad->where('seotitle', '=', Request::current()->param('seotitle'))->limit(1)->find();
if ($ad->loaded()) {
$this->id_ad = $ad->id_ad;
}
}
示例12: action_index
public function action_index()
{
$this->before('/pages/maps');
$this->template->title = __('Map');
$this->template->height = Core::get('height', '100%');
$this->template->width = Core::get('width', '100%');
$this->template->zoom = Core::get('zoom', core::config('advertisement.map_zoom'));
$this->template->height_thumb = Core::config('image.height_thumb') / 4;
$this->template->width_thumb = Core::config('image.width_thumb') / 4;
if (Model_User::get_userlatlng()) {
$this->template->center_lon = $_COOKIE['mylng'];
$this->template->center_lat = $_COOKIE['mylat'];
} else {
$this->template->center_lon = Core::get('lon', core::config('advertisement.center_lon'));
$this->template->center_lat = Core::get('lat', core::config('advertisement.center_lat'));
}
$ads = new Model_Ad();
$ads->where('status', '=', Model_Ad::STATUS_PUBLISHED)->where('address', 'IS NOT', NULL)->where('latitude', 'IS NOT', NULL)->where('longitude', 'IS NOT', NULL);
//filter by category
if (core::get('category') !== NULL) {
$category = new Model_Category();
$category->where('seoname', '=', core::get('category'))->cached()->limit(1)->find();
if ($category->loaded()) {
$ads->where('id_category', 'IN', $category->get_siblings_ids());
}
}
//filter by location
if (core::get('location') !== NULL) {
$location = new Model_location();
$location->where('seoname', '=', core::get('location'))->cached()->limit(1)->find();
if ($location->loaded()) {
$ads->where('id_location', 'IN', $location->get_siblings_ids());
}
}
//if ad have passed expiration time dont show
if (core::config('advertisement.expire_date') > 0) {
$ads->where(DB::expr('DATE_ADD( published, INTERVAL ' . core::config('advertisement.expire_date') . ' DAY)'), '>', Date::unix2mysql());
}
//if only 1 ad
if (is_numeric(core::get('id_ad'))) {
$ads = $ads->where('id_ad', '=', core::get('id_ad'));
}
$ads = $ads->order_by('published', 'desc')->limit(Core::config('advertisement.map_elements'))->find_all();
$this->template->ads = $ads;
}
示例13: before
/**
* Automatically executed before the widget action. Can be used to set
* class properties, do authorization checks, and execute other custom code.
*
* @return void
*/
public function before()
{
$ads = new Model_Ad();
$ads->where('status', '=', Model_Ad::STATUS_PUBLISHED);
switch ($this->ads_type) {
case 'popular':
$id_ads = array_keys(Model_Visit::popular_ads());
if (count($id_ads) > 0) {
$ads->where('id_ad', 'IN', $id_ads);
}
break;
case 'featured':
$ads->where('featured', 'IS NOT', NULL)->where('featured', 'BETWEEN', array(DB::expr('NOW()'), Date::unix2mysql(time() + core::config('payment.featured_days') * 24 * 60 * 60)))->order_by('featured', 'desc');
break;
case 'latest':
default:
$ads->order_by('published', 'desc');
break;
}
$ads = $ads->limit($this->ads_limit)->cached()->find_all();
//die(print_r($ads));
$this->ads = $ads;
}
示例14: before
/**
* Automatically executed before the widget action. Can be used to set
* class properties, do authorization checks, and execute other custom code.
*
* @return void
*/
public function before()
{
$ad = new Model_Ad();
$user_ads = clone $ad;
//get current ad do not filter by user since admin also can see
$ad->where('seotitle', '=', Request::current()->param('seotitle'))->limit(1)->find();
if ($ad->loaded() and Auth::instance()->logged_in()) {
$user = Auth::instance()->get_user();
if ($user->id_role == Model_Role::ROLE_ADMIN or $user->id_user == $ad->id_user) {
$this->ad = $ad;
$this->user_ads = $user_ads->where('id_user', '=', $ad->id_user)->find_all();
}
}
}
示例15: action_moderate
/**
* Action MODERATION
*/
public function action_moderate()
{
//template header
$this->template->title = __('Moderation');
$this->template->meta_description = __('Moderation');
$this->template->scripts['footer'][] = 'js/jquery.toolbar.js';
$this->template->scripts['footer'][] = '/js/oc-panel/moderation.js';
//find all tables
$ads = new Model_Ad();
$res_count = $ads->where('status', '=', Model_Ad::STATUS_NOPUBLISHED)->count_all();
if ($res_count > 0) {
$pagination = Pagination::factory(array('view' => 'oc-panel/crud/pagination', 'total_items' => $res_count, 'items_per_page' => core::config('advertisement.advertisements_per_page')))->route_params(array('controller' => $this->request->controller(), 'action' => $this->request->action()));
$ads = $ads->where('status', '=', Model_Ad::STATUS_NOPUBLISHED)->order_by('created', 'desc')->limit($pagination->items_per_page)->offset($pagination->offset)->find_all();
$this->template->content = View::factory('oc-panel/pages/moderate', array('ads' => $ads, 'pagination' => $pagination));
} else {
Alert::set(Alert::INFO, __('You do not have any advertisements waiting to be published'));
$this->template->content = View::factory('oc-panel/pages/moderate', array('ads' => NULL));
}
}