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


Recent Events
  • 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.

  • 21/11/2023 BLACK FRIDAY 23 is coming

    BIG SALE, 35% discount for all our extensions. Use BF23 coupon code. Hurry up the discount is valid till 27 November.


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 11 Years, 10 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 11 Years, 10 Months ago Karma: 748
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 11 Years, 10 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 11 Years, 10 Months ago Karma: 748
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 11 Years, 10 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 11 Years, 10 Months ago Karma: 748
We suppose you need {$UserLogin} variable instead of {$UserName} variable.

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