Displaying 20 results from an estimated 600 matches similar to: "ez-where headscratch"
2006 Apr 18
3
ez_where query question
I''m having fun composing queries with ez_where, but am stuck on how to
formulate the following using the ez syntax:
(begin_date >= ? OR end_date >= ?) AND (description LIKE ? OR name LIKE ?)
There are two clauses, each containing OR operators (the ez ''any'' syntax)
but both clauses must evaulate to true for a match.
Can anyone suggest the proper way to construct
2006 Feb 24
2
raking my brain to fix this
I am ''raking'' my brain to fix this problem - I have searched, googled,
looked through rake documentation, wiki.rubyonrails and I can''t fix...
This works
$ rake plugindoc
(in /home/craig/ruby-db/th-db)
rdoc -o doc/plugins/ez_where --title ''Ez Where Plugin Documentation'' --
line-numbers --inline-source -T html
2008 Jan 16
4
How to test if one range of dates overlaps another?
Hi all,
I have a situation with a recurring billing application where I need
to test if one range of dates "overlaps" another range of dates. Does
anyone know a rails find or mysql select statement that will test for
this? Here are the details:
* Recurringcharge items have a start_date and an end_date that
represent the period of time that the charges should occur.
* Statement items
2006 Feb 22
2
Using ez_where
Hi All,
I am trying to pass values to ez_where to construct my conditions. I
need
to know how the params need to be formated for ez_where.
My search class looks like this:
def search
@display_ad = DisplayAd.new(params[:display_ad])
cond = Caboose::EZ::Condition.new do
pub_date == ''@display_ad.pub_date''
io_number =~
2006 Aug 02
5
Fun with ez_where
I''ve been trying to use the ez_where plugin to create a dynamic finder.
The structure looks somehing like this..
=== controller ===
def list
attribute_filter = params[:filter]
@filter = Caboose::EZ::Condition.new :table do
attribute <=> attribute_filter if attribute_filter
end
#
... do the find with the @filter
#
end
=== view ===
....
<%= link_to
2006 Jul 28
2
ez_where: Stuck Again
I just keep thinking this is going to slice through queries like a hot knife
through butter, but... there''s something I''m not getting. Here''s the gist:
# get the people like the search criteria
Members.find(:all, :conditions => [''first LIKE ? OR last LIKE ?'',
params[:search], params[:search])
joined with the alternative of
2006 Apr 15
2
ez_where : i''m puzzled
I have the following code:
condition_clause = "%#{@phrase}%"
logger.info "condition is #{condition_clause}"
unless @phrase.nil?
condition = Caboose::EZ::Condition.new :affiliates do
affiliate_name =~ "%#{@phrase}%" # <<< here''s the problem
end
options[:conditions] = condition.to_sql
logger.info "ajax
2006 Jun 14
6
find and LIKE ''xxx%'' clause
Hi there !
I try to figure out how to do something like this in Rails :
SELECT * FROM my_table WHERE name LIKE ''GOGONAM%''
My problem is the % and the quotes.
>From now, I do like this :
searched_name = params[:name]+''%''
user = MyTable.find(:all, :conditions => ["name LIKE ?", searched_name])
But is there a more gracefull way to do a LIKE
2006 Feb 15
10
STI Question
Hi everyone,
I have 3 types of people (for now):
Staff
Faculty
Students
To break them up into classes, but keep them in the same People table,
I''ve broken them up like so (code and ''ends'' snipped):
class Person < ActiveRecord::Base
class Employee < Person
class Staff < Employee
class Faculty < Employee
class Student < Employee
So, when I insert
2006 Jan 31
11
ez_where plugin updated features.
Friends-
I wanted to let people know that there is a new experimental release
of this plugin. I would love feedback on syntax and features. There
is now a full test suite with fixtures that covers all the available
syntax. Look at the test suite for more syntax possibilities. There
have been many additions since my last release. Fabien Atelier has
been working on this with me and has
2006 Apr 16
3
variable variables?
Hi everyone,
Does Ruby support variable variables like PHP
(http://www.php.net/manual/en/language.variables.variable.php)? Or do I have
to use eval, like
some_hash.each_pair{|key, pair|
eval "#{key} = #{value}"
}
Or is there some other way?
I''m actually trying to figure this out in order to use ez_where to create
its conditions from a hash, so if this isn''t even
2006 Jun 30
3
New release of ez-where plugin
Hello friends-
There is a new release of the ez-where plugin. This plugin makes it
easy to do complex ActiveRecord queries without writing any SQL. Ruby
operators are mapped to SQL operators like so:
foo == ''bar'' #=> ["foo = ?", ''bar'']
foo =~ ''%bar'' #=> ["foo LIKE ?", ''%bar'']
2006 Feb 19
8
building multiple find conditions
I am trying to allow for AND type ''find'' but to allow for simply a
single set of find criteria.
controller code...
@vw_string = @vw_string1 = @vw_string2 = @vw_string3 = []
if params[:beg_intake_date] != "" then
@vw_string1 = ["intake_date between ? and ?",
params[:beg_intake_date], params[:end_intake_date] ]
end
if
2009 Oct 01
1
Help me replace a for loop with an "apply" function
...if that is possible
My task is to find the longest streak of continuous days a user participated
in a game.
Instead of writing an sql function, I chose to use the R's rle function, to
get the longest streaks and then update my db table with the results.
The (attached) dataframe is something like this:
day user_id
2008/11/01 2001
2008/11/01 2002
2008/11/01 2003
2005 May 19
5
[OT] Sqlite2 question
So, under Sqlite2, if I want to update a database''s schema, I have to
dump the DB, modify the table''s structure, then go and modify EVERY
insert statement.
The insert statements look like (from memory):
INSERT INTO my_table VALUES (''some_id'', ''some_val'', '''', '''', '''',
''some_other
2007 Aug 30
1
belongs_to with foreign keys that reference non primary key columns
Hello,
I have a situation where the foreign key into a table doesn''t
correspond to that table''s primary key:
my_table
-------------
id (pk)
name
...
other_table
--------------
id (pk)
my_table_name (fk references my_table(name))
...
I want to be able to say something like:
class OtherTable < ActiveRecord::Base
belongs_to :my_table, :foreign_key => { :my_table_name
2006 Apr 22
4
Slice and dice plugin
I''ve been playing around with some easier ways of specifying
conditions in active record, and have come up with a little plugin
that some may find useful. Currently active record finder and
calculations methods can take a :conditions option with a string or
array listing some sql conditions, eg:
Animals.find :first, :conditions => "name = ''Tiger''"
My
2007 Apr 29
2
Validate unique within date range?
I''m setting up a simple system for listing products and specials. I''m
looking for a way to validate that only one special can exist per
product per date range. For example, if a product is on sale from
2007-04-29 to 2007-05-10, you cannot create a special for that product
that starts on 2007-05-09.
What''s the best way to do this with Rails? I''m fairly new to
2006 Apr 10
1
Add Column After Column in Migrations
Adding a column to a table just places the column at the end, but I
like to keep related columns together. Is there a way to specify
where the column is added in a table with migrations? For example, in
MySQL you can do:
ALTER TABLE my_table ADD COLUMN new_column INT AFTER other_column
I was hoping migrations would support something like this:
add_column :my_table, :new_column, :integer,
2010 Jun 10
1
Can RMySQL be used for a paramterized query?
I have not found anything about this except the following from the DBI
documentation :
Bind variables: the interface is heavily biased towards queries, as opposed
> to general
> purpose database development. In particular we made no attempt to define
> “bind
> variables”; this is a mechanism by which the contents of R/S objects are
> implicitly
> moved to the database during SQL