• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: db access in CMSMS 2
PostPosted: Wed Oct 05, 2016 2:37 pm 
Offline
New Member
New Member

Joined: Wed Oct 05, 2016 2:09 pm
Posts: 3
Here's my UDT called UserListing
$gCms = cmsms();
$db = $gCms->getDb();
$sql = "SELECT * FROM " . cms_db_prefix() . "module_feusers_users";
$dbresult = $db->Execute($sql);
$count = $dbresult ->RecordCount();
$result = array();
while($dbrow = $dbresult->FetchRow()) {
$result[] = $dbrow;
}



$smarty ->assign(result,$result);
$smarty ->assign(count,$count);

and my page:
{UserListing}
<p>{$count} records on file</p>
{foreach from=$result item='entry'}
<p>Email:{$entry.email}</br>
{/foreach}

$count shows correctly so I know result is being passed as I get
the correct number of lines from the loop
But the loop shows no $entry.email or any other field

What am I missing ?


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: db access in CMSMS 2
PostPosted: Wed Oct 05, 2016 2:55 pm 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Mon Jan 29, 2007 4:47 pm
Posts: 1707
Try the following to see what is inside {$entry}...
Code:
{foreach from=$result item='entry'}
{$entry|print_r:1}

_________________
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).


Code of Conduit | CMSMS Docs
Help Support CMSMS
My developer Page on the Forge | Yet another blog about CMSMS

GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!



Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: db access in CMSMS 2
PostPosted: Wed Oct 05, 2016 3:04 pm 
Offline
New Member
New Member

Joined: Wed Oct 05, 2016 2:09 pm
Posts: 3
Here's 1 record from the loop:
Array ( [id] => 134 [username] => Anderson [password] => ---------------------------------------------- [createdate] => 2014-07-31 20:38:21 [expires] => 2014-07-31 23:59:59 [nonstd] => 0 [disabled] => 0 [salt] => --------------------------------------[force_newpw] => 0 [force_chsettings] => 0 )


Last edited by Jo Morg on Wed Oct 05, 2016 4:12 pm, edited 1 time in total.
Security


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: db access in CMSMS 2
PostPosted: Wed Oct 05, 2016 3:18 pm 
Offline
New Member
New Member

Joined: Wed Oct 05, 2016 2:09 pm
Posts: 3
<p>User:{$entry['username']} ID:{$entry['id']} </br>
WORKED !!!

Thanks so much. I've spent hours trying to figure it out


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: db access in CMSMS 2
PostPosted: Wed Oct 05, 2016 4:10 pm 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Mon Jan 29, 2007 4:47 pm
Posts: 1707
In Smarty you can use both the PHP array notation and the Smarty dot notation to access arrays:
Code:
{$entry['username']} = {$entry.username}

Apparently you were trying to get data that wasn't there to begin with.

_________________
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).


Code of Conduit | CMSMS Docs
Help Support CMSMS
My developer Page on the Forge | Yet another blog about CMSMS

GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!



Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
Display posts from previous:  Sort by  
Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
A2 Hosting