[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

MySQL Query - Stupid question...

Jeff Miller

4/4/2008 11:50:00 PM

Hello,
Although I've dealt with many many SQL queries and whatnot, I actually
don't know how to return the number of rows it returned... I'm using the
MySQL gem and making my queries like this:

db1 = Mysql.connect("localhost", "root", "root", "project")
@new_entries = db1.query("SELECT * FROM new_entries")

...but what can I do to get the number of rows as well as the data from
the table?

Thanks,
- Jeff Miller
--
Posted via http://www.ruby-....

2 Answers

Steve Ross

4/5/2008 2:15:00 AM

0

On Apr 4, 2008, at 4:49 PM, Jeff Miller wrote:

> Hello,
> Although I've dealt with many many SQL queries and whatnot, I actually
> don't know how to return the number of rows it returned... I'm using
> the
> MySQL gem and making my queries like this:
>
> db1 = Mysql.connect("localhost", "root", "root", "project")
> @new_entries = db1.query("SELECT * FROM new_entries")
>
> ...but what can I do to get the number of rows as well as the data
> from
> the table?
>
> Thanks,
> - Jeff Miller

@new_entries.num_rows



Jeff Miller

4/18/2008 10:52:00 PM

0

Thanks, that worked.

However, I'm doing another query in a different app using RoR... How can
I achieve the same thing? I want to get the number of rows off a query
such as this:

@grab_new_entries = NewEntries.connection.select_all("SELECT displayname
AS displayname FROM new_entries")

@grab_new_entries.num_rows didn't work....

Thanks,
- Jeff Miller
--
Posted via http://www.ruby-....