Babulesnik
Member
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
Babulesnik
Member
RE: Sql bug?
Please someone check with ourselves sql.getRows () or tell me where my mistake.
07-21-2011 10:36 AM
Esenthel
Administrator
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
Babulesnik
Member
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
Other types of use of <'> does not apply
07-21-2011 11:59 AM