Home News Contact Us Forum About Us Demos Products F.A.Q.
Shopping Cart
You currently have 0 items in your cart.


Recent Events
  • 23/11/2024 Black Friday 2024

    BIG SALE, 30% discount for all our extensions. Use BF24 coupon code. Hurry up the discount is valid till 3 December.

  • 31/12/2023 New Year SALE

    We are glad to announce New Year SALE. 25% discount for all our extensions. Use NY24 coupon code. Hurry up the discount is valid till 7 January.


2Checkout.com, Inc. is an authorized retailer of goods and services provided by ARI Soft. 2CheckOut




Follow us on twitter



Welcome, Guest
Please Login or Register.    Lost Password?

Getuser (from joomla) for query
(1 viewing) (1) Guest
Go to bottomPage: 12
TOPIC: Getuser (from joomla) for query
#29288
Getuser (from joomla) for query 12 Years, 5 Months ago Karma: 0
Is it possible to get the current (signed in) joomla user, to be used in my data tables query? The query will be accessing an external SQL database. But I need to show information that is specific to the current user only. Is this possible?
The administrator has disabled public write access.
 
#29290
Re:Getuser (from joomla) for query 12 Years, 5 Months ago Karma: 760
Hello,

It is possible to use {$UserId} predefined variable in WHERE clause of an SQL query. A sample query:

Code:


SELECT
 id,
 title
FROM
 #__content
WHERE
 created_by = {$UserId}



Regards,
ARI Soft
The administrator has disabled public write access.
 
#29291
Re:Getuser (from joomla) for query 12 Years, 5 Months ago Karma: 0
If my SQL database is external, does the {$UserId} automatically know to use the Joomla user id? Also, we'd really need to use user name, not user id. Is that possible?
The administrator has disabled public write access.
 
#29292
Re:Getuser (from joomla) for query 12 Years, 5 Months ago Karma: 760
You can use it for an external database as well for Joomla! database. You can also use {$UserName} and {$UserLogin} variables.

Regards,
ARI Soft
The administrator has disabled public write access.
 
#29298
Re:Getuser (from joomla) for query 12 Years, 5 Months ago Karma: 0
Here is my query, which returns no data:
SELECT UserID, OrderDate, PONum
FROM `openorders`
WHERE
UserID = {$UserName}


However, when I actually type the value for user id it works...so this works:

SELECT UserID, OrderDate, PONum
FROM `openorders`
WHERE
UserID = 'ds124'


What do I need to do in order for the top query to work with the dynamic userName?
The administrator has disabled public write access.
 
#29299
Re:Getuser (from joomla) for query 12 Years, 5 Months ago Karma: 760
We suppose you need {$UserLogin} variable instead of {$UserName} variable.

Regards,
ARI Soft
The administrator has disabled public write access.
 
Go to topPage: 12