1. bennu500
  2. Support
  3. Sunday, December 06 2015, 05:37 PM
Hello,
Thanks for a great extension!

I just found a problem with a custom script I have relating to easy-profile. I upload my user accounts using j-import and was looking at some of the newly created users and found out that until they log in for the first time the jsn_users records do not exist. My script tries to look up a custom field I use with easy-profile from a username provided, but for accounts that are present but not yet in use the script thinks there is no account since jsn_user is not available yet.

$db->setQuery("SELECT jsn.status,jsn.firstname,jsn.lastname,u.email,u.name FROM #__jsn_users jsn LEFT JOIN #__users u ON jsn.id =u.id WHERE u.username = '".$searchUser."' LIMIT 1";);
$db->execute();
$num_rows = $db->getNumRows();
if ($num_rows == 0)

I think it is failing because the query is not getting all the results since jsn.status, jsn.firstname, and jsn.lastname do not exist?

I figured there are a few ways to possibly solve this.
1. I could see if you have a way to trigger the fields generation and input the default values that could be integrated with the mass importer j-import.
2. is there a way to run a query in phpmyadmin or a PHP script to manually trigger jsn_users to be created and have the defaults entered for all accounts that have not yet logged in before?
3. I could possibly change my above query to pull the lastvisitDate and check if it is a real date, the default of 0000-00-00 00:00:00 (account never used) or if it does not exist. I don't know programming at all. The person who wrote the script for me is no longer available.

Any help you can provide would be appreciated.

Peter
admin Accepted Answer
Admin
Hi,
I think there are some error on your DB Query,
1. you apply LEFT JOIN, but first table is #__jsn_users instead #__users. so try to reverse the tables. With this if not exists record on #__jsn_users table you will still record from #__users
2. jsn.status is not a default column, you have a field with this alias?
3. Missing "AS" statement to set alias for tables

So try query like this:
SELECT jsn.firstname,jsn.lastname,u.email,u.name FROM #__users AS u LEFT JOIN #__jsn_users AS ON u.id =jsn.id WHERE....
  1. more than a month ago
  2. Support
  3. # 1
  • Page :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.
Sorry, the discussion is currently locked. You will not be able to post a reply at the moment.