Welcome to Geeklog, Anonymous Saturday, April 20 2024 @ 07:10 am EDT
Geeklog Forums
Is there a reverse COM_getPermSQL()?
Status: offline
LWC
Forum User
Full Member
Registered: 02/19/04
Posts: 818
I want a code that tests all kinds of conditions and stops if at least one of them fails.
Just as a random example (pretending such a function is called COM_getPermSQL_reverse):
$sql = "SELECT '' FROM gl_stories WHERE (sid='foo' OR sid='bar')" . COM_getPermSQL_reverse("AND");
$result = DB_query($sql);
if (!DB_numRows($result))
echo "At least one of these stories is out of your reach, so I decided you can't see the other either";
So is there such a thing?
Until then, I have to call the SQL twice:
$sql = "SELECT '' FROM gl_stories WHERE sid='foo' OR sid='bar'";
$result = DB_query($sql);
$sql1 = DB_numRows($result);
if ($sql1 > 0 && !SEC_inGroup('Root')) {
$sql = "SELECT '' FROM gl_stories WHERE (sid='foo' OR sid='bar')" . COM_getPermSQL("AND");
$result = DB_query($sql);
$sql2 = DB_numRows($result);
if ($sql2 < $sql1)
echo "At least one of these stories is out of your reach, so I decided you can't see the other either";
}
Just as a random example (pretending such a function is called COM_getPermSQL_reverse):
Text Formatted Code
$sql = "SELECT '' FROM gl_stories WHERE (sid='foo' OR sid='bar')" . COM_getPermSQL_reverse("AND");
$result = DB_query($sql);
if (!DB_numRows($result))
echo "At least one of these stories is out of your reach, so I decided you can't see the other either";
So is there such a thing?
Until then, I have to call the SQL twice:
Text Formatted Code
$sql = "SELECT '' FROM gl_stories WHERE sid='foo' OR sid='bar'";
$result = DB_query($sql);
$sql1 = DB_numRows($result);
if ($sql1 > 0 && !SEC_inGroup('Root')) {
$sql = "SELECT '' FROM gl_stories WHERE (sid='foo' OR sid='bar')" . COM_getPermSQL("AND");
$result = DB_query($sql);
$sql2 = DB_numRows($result);
if ($sql2 < $sql1)
echo "At least one of these stories is out of your reach, so I decided you can't see the other either";
}
5
3
Quote
Status: offline
LWC
Forum User
Full Member
Registered: 02/19/04
Posts: 818
Do you mean COM_getPermSQL("WHERE NOT" ) / COM_getPermSQL("AND NOT" )? It brings you everything you have no access to. It doesn't tell you if at least one condition failed.
What I basically need to know is whether (a non blank) COM_getPermSQL actually had any effect on the query or did you just get what you would have got if you didn't include COM_getPermSQL in the query.
What I basically need to know is whether (a non blank) COM_getPermSQL actually had any effect on the query or did you just get what you would have got if you didn't include COM_getPermSQL in the query.
4
4
Quote
All times are EDT. The time is now 07:10 am.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content