jokecoat
Posts: 43
|
| Posted: 06/18/2011, 10:01 AM |
|
Add/update grid:
I need to lookup a default value for the field player_id.
In the properties of player_id i put this CCDLookUp("player_id","jos_users","id="&CCGetUserId(),DBjoomla) in Default value.
But i get a blank screen, so it doesn't work. I checked the documents but i can't figure out what i'm doing wrong.
Any help would be appriciated.
|
 |
 |
jjrjr2
Posts: 131
|
| Posted: 06/18/2011, 11:02 AM |
|
Hi
Not sure if you can do this in the Default Value for a control since I do not know if You can have 2 PHP statements in the Property Box..
I am assuming your connection name for your database is DBjoomla....
Try
$db= new clsDBDBjoomla();CCDLookUp("player_id","jos_users", "id=".$db->ToSql(CCGetUserId(),ccsInteger),$db)
If you cannot have 2 PHP commands as a default value you can do several things
Create a function like the above and make it look this this..
function getPlayerID(){
$db= new clsDBDBjoomla();
$playerID=CCDLookUp("player_id","jos_users", "id=".$db->ToSql(CCGetUserId(),ccsInteger),$db) ;
return $playerID;
}
And put getPlayerID() into the default value.
OR
Create a custom code for the control in the Before Show event like so:
$db= new clsDBDBjoomla();
$Container->YourCCSComponentName->SetValue(CCDLookUp("player_id","jos_users", "id=".$db->ToSql(CCGetUserId(),ccsInteger),$db) );
OR.. OR
The easiest is use DLookup action in the BeforeShow Event for that label or field.
John
LOL There are always many ways to skin a cat..
_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
Real Web Development At: http://RealWebDevelopment.us |
 |
 |
jokecoat
Posts: 43
|
| Posted: 06/18/2011, 11:44 AM |
|
Thank you for your reply.
I'm trying your last suggestion (didn't know that option was available...)
But i don't get the where right.
This is the line CCS created:
$ccs_result = CCDLookUp("player_id", "jos_users", "id=" & CCGetUserId(), $Page->Connections["joomla"]);
But it doesn't return anything.
when i hardcode the userid...
$ccs_result = CCDLookUp("player_id", "jos_users", "id=64", $Page->Connections["joomla"]);
It works.
So how to work this with CCGetUserId()?
|
 |
 |
jjrjr2
Posts: 131
|
| Posted: 06/18/2011, 11:49 AM |
|
Replace the & with a .
the . is the php concat operator....
The where for the DLookup should be:
"id=".CCGetUserId()
OR
"id=".CCGetSession("UserID","")
LOL Again more than one way to skin a cat....
BTW since your database connection is joomla NOT DBjoomla
The creations of the new database objects in the above code would be:
$db = new clsDBjoomla();
_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
Real Web Development At: http://RealWebDevelopment.us |
 |
 |
jokecoat
Posts: 43
|
| Posted: 06/18/2011, 11:53 AM |
|
Thank you very much!! It works.
|
 |
 |
|