About Store Forum Documentation Contact



Post Reply 
Sql bug?
Author Message
Babulesnik Offline
Member

Post: #1
Sql bug?
I created a class for working with MSSQL based on EE::Sql.Everything works fine except sql.getRows()

The code of my method:
Code:
Bool SQLManagement::FindUser(Str Condition)
{
  if(!sql.getRows(TableName,Condition,&messages))return false;

  return true;
}

When I run this function I get a negative result. While such a record in my database there.
Code:
{
     if(Sqlmanagement.FindUser ("login=user1"))result="YES";
     if(!Sqlmanagement.FindUser("login=user1"))result="NO" ;
   }

Also, if I write "id = 0" or "id = 25" the result is always a positive "yes"
While the table contains only 2 entries.

example:
Code:
if(Sqlmanagement.FindUser ("id=25"))result="YES";
  if(!Sqlmanagement.FindUser("id=25"))result="NO" ;


Attached File(s) Image(s)
   
07-19-2011 12:55 PM
Find all posts by this user Quote this message in a reply
Babulesnik Offline
Member

Post: #2
RE: Sql bug?
Please someone check with ourselves sql.getRows () or tell me where my mistake.
07-21-2011 10:36 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #3
RE: Sql bug?
return value of getRows is success of the operation (not if the element exists) - read comments carefully on the methods

you may want to use getRowsNum(..)>=1
07-21-2011 10:49 AM
Find all posts by this user Quote this message in a reply
Babulesnik Offline
Member

Post: #4
RE: Sql bug?
Thank you very much getRowsNum () is more suited to me. I found the error. If I compare the string type must put quotes < ' > For example: if (sql.getRowsNum (TableName, "login = user1", & messages)> = 1) - so it will not work. if (sql.getRowsNum (TableName, "login = 'user1'", & messages)> = 1) - works fine grin

Other types of use of <'> does not apply
07-21-2011 11:59 AM
Find all posts by this user Quote this message in a reply
Post Reply