mysql_num_rows

Discussion forum for MOD Writers regarding MOD Development.
Locked
tommekemc
Registered User
Posts: 457
Joined: Wed May 14, 2008 6:36 pm
Location: Belgium
Contact:

mysql_num_rows

Post by tommekemc » Wed Jun 25, 2008 6:56 am

is there any dbal for mysql_num_rows?
I found sql_num_queries(), but this is something else...
or can I just use mysql_num_rows?
my sig
my projects

images deleted because of the 6kb (wtf?) rule...

User avatar
david63
Registered User
Posts: 16330
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Name: David Wood
Contact:

Re: mysql_num_rows

Post by david63 » Wed Jun 25, 2008 7:06 am

The only one I can see is sql_affectedrows() which may give you what you want.
tommekemc wrote:can I just use mysql_num_rows?
Only if you do not plan releasing it as part of a mod.
David
Remember: You only know what you know and - you don't know what you don't know!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored

tommekemc
Registered User
Posts: 457
Joined: Wed May 14, 2008 6:36 pm
Location: Belgium
Contact:

Re: mysql_num_rows

Post by tommekemc » Wed Jun 25, 2008 7:20 am

well, that's the problem.
what if I need to use it in my mod?
(did it in another way now...)
I think sql_affectedrows() returns the rows that have changed, isn't it?
my sig
my projects

images deleted because of the 6kb (wtf?) rule...

janmyszkier
Registered User
Posts: 294
Joined: Tue Oct 09, 2007 4:53 pm

Re: mysql_num_rows

Post by janmyszkier » Wed Jun 25, 2008 7:29 am

no it returns the number of rows that are inside the result of an sql query

tommekemc
Registered User
Posts: 457
Joined: Wed May 14, 2008 6:36 pm
Location: Belgium
Contact:

Re: mysql_num_rows

Post by tommekemc » Wed Jun 25, 2008 8:20 am

Get the number of affected rows by the last INSERT, UPDATE, REPLACE or DELETE query associated with link_identifier .
and if I check the code it says:

Code: Select all

return ($this->db_connect_id) ? @mysql_affected_rows($this->db_connect_id) : false;
ir means: return mysql_affected_rows (described on top) or return false...
this does not return the amount of rows you've stored in your var...
my sig
my projects

images deleted because of the 6kb (wtf?) rule...

janmyszkier
Registered User
Posts: 294
Joined: Tue Oct 09, 2007 4:53 pm

Re: mysql_num_rows

Post by janmyszkier » Wed Jun 25, 2008 8:30 am

works fine on SELECT though... just applied it to my mod.

tommekemc
Registered User
Posts: 457
Joined: Wed May 14, 2008 6:36 pm
Location: Belgium
Contact:

Re: mysql_num_rows

Post by tommekemc » Wed Jun 25, 2008 9:55 am

well, ok :)
thanx!
my sig
my projects

images deleted because of the 6kb (wtf?) rule...

Paul
Infrastructure Team Leader
Infrastructure Team Leader
Posts: 25230
Joined: Sat Dec 04, 2004 3:44 pm
Location: The netherlands.
Name: Paul Sohier
Contact:

Re: mysql_num_rows

Post by Paul » Wed Jun 25, 2008 11:25 am

janmyszkier wrote:works fine on SELECT though... just applied it to my mod.
Only you should not use i on a SELECT, your MOD will be denied for that :).

You actually dont need num_rows, there are always replacements that can be used instead, sizeof at the full resultset, or a do while to check if there is any result, or a COUNT query.
Knock knock
Race condition
Who's there?

My BlogMy Photosmy phpBB Extensionscustom phpBB work & Development

janmyszkier
Registered User
Posts: 294
Joined: Tue Oct 09, 2007 4:53 pm

Re: mysql_num_rows

Post by janmyszkier » Wed Jun 25, 2008 12:34 pm

so why do PHPBB code has SELECT and affectedrows in it while it is forbidden? I bet i saw it somewhere, becuase i copied the idea from phpbb to my mod :)

Paul
Infrastructure Team Leader
Infrastructure Team Leader
Posts: 25230
Joined: Sat Dec 04, 2004 3:44 pm
Location: The netherlands.
Name: Paul Sohier
Contact:

Re: mysql_num_rows

Post by Paul » Wed Jun 25, 2008 12:37 pm

phpBB3 never uses affected rows on a select. Its not meant for select, its meant for update/delete/insert only.
Knock knock
Race condition
Who's there?

My BlogMy Photosmy phpBB Extensionscustom phpBB work & Development

janmyszkier
Registered User
Posts: 294
Joined: Tue Oct 09, 2007 4:53 pm

Re: mysql_num_rows

Post by janmyszkier » Wed Jun 25, 2008 12:48 pm

so i guess the only way is a 'while' ?

Paul
Infrastructure Team Leader
Infrastructure Team Leader
Posts: 25230
Joined: Sat Dec 04, 2004 3:44 pm
Location: The netherlands.
Name: Paul Sohier
Contact:

Re: mysql_num_rows

Post by Paul » Wed Jun 25, 2008 1:00 pm

it depends on what you want to use it for, there are several replacements for in certian situations.
Knock knock
Race condition
Who's there?

My BlogMy Photosmy phpBB Extensionscustom phpBB work & Development

tommekemc
Registered User
Posts: 457
Joined: Wed May 14, 2008 6:36 pm
Location: Belgium
Contact:

Re: mysql_num_rows

Post by tommekemc » Sat Oct 25, 2008 9:57 am

me again, I'm wondering how I can check if there's anything fetched or nothing, how do I do that?
for example:

Code: Select all

if(mysql_num_rowq($sql)==1){
//do code
}else{
//do something else
}
my sig
my projects

images deleted because of the 6kb (wtf?) rule...

User avatar
A_Jelly_Doughnut
Former Team Member
Posts: 34457
Joined: Sat Jan 18, 2003 1:26 am
Location: Where the Rivers Run
Contact:

Re: mysql_num_rows

Post by A_Jelly_Doughnut » Sat Oct 25, 2008 7:04 pm

If nothing was fetched, $db->sql_fetchrow will return an empty array. So

Code: Select all

if (!($row = $db->sql_fetchrow($result)))
{
   // The query had no results
}
A Donut's Blog
"Bach's Prelude (Cello Suite No. 1) is driving Indiana country roads in Autumn" - Ann Kish

tommekemc
Registered User
Posts: 457
Joined: Wed May 14, 2008 6:36 pm
Location: Belgium
Contact:

Re: mysql_num_rows

Post by tommekemc » Sun Oct 26, 2008 6:44 am

thanx for your reply!
wasn't 100% sure, so I thought I'dd ask it to the pro's :p
my sig
my projects

images deleted because of the 6kb (wtf?) rule...

Locked

Return to “[3.0.x] MOD Writers Discussion”

cron