PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.ruby > trouble adding date query variable
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
trouble adding date query variable

Réponse
 
LinkBack Outils de la discussion
Vieux 24/02/2008, 22h24   #1
laredotornado
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut trouble adding date query variable

Hi,

I'm trying to build a search form with a date input field, displayed
like this:

<%= date_select(:purchase_date, params[:purchase_date]) %>

But I'm having trouble adding the criteria in my controller. So far,
I have:

if !search[:purchase_date].blank?
conditions << 'purchase_date >= ?'
conditions << "#{search[:purchase_date]}"
end
find(:all, :conditions => conditions, :page => {:size
=> page_size, :current => page_num} )

But the query gets run in a weird way, below:

SELECT count(ec_orders.id) AS count_ec_orders_id FROM `ec_orders`
WHERE purchase_date >= '(3i)24(1i)2006(2i)2')


What is the right way to get the date to be displayed normally in the
SQL query? - Dave
  Réponse avec citation
Vieux 25/02/2008, 15h25   #2
Ilan Berci
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: trouble adding date query variable

laredotornado wrote:
> Hi,
>
> I'm trying to build a search form with a date input field, displayed
> like this:
>
> <%= date_select(:purchase_date, params[:purchase_date]) %>
>
> But I'm having trouble adding the criteria in my controller. So far,
> I have:
>
> if !search[:purchase_date].blank?
> conditions << 'purchase_date >= ?'
> conditions << "#{search[:purchase_date]}"
> end
> find(:all, :conditions => conditions, :page => {:size
> => page_size, :current => page_num} )
>
> But the query gets run in a weird way, below:
>
> SELECT count(ec_orders.id) AS count_ec_orders_id FROM `ec_orders`
> WHERE purchase_date >= '(3i)24(1i)2006(2i)2')
>
>
> What is the right way to get the date to be displayed normally in the
> SQL query? - Dave


conditions => ["purchase_date >= ?", search[:purchase_date].to_s(:db)]

hth

ilan
--
Posted via http://www.ruby-forum.com/.

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 18h17.


Édité par : vBulletin® version 3.7.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,07954 seconds with 10 queries