Skip to content

Instantly share code, notes, and snippets.

@Uriel29
Created September 11, 2014 19:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Uriel29/df9d1055b053978bf14c to your computer and use it in GitHub Desktop.
Save Uriel29/df9d1055b053978bf14c to your computer and use it in GitHub Desktop.
Achar nome de usuário a partir do ID. Banco de dados do Joomla! Usamos isso no Seblod!
<?php
$id_user = $cck->getValue('usuario');//recebe ID do usuário
// conexão com banco e consulta
$db = & JFactory::getDBO();
$query = "SELECT username FROM #__users WHERE id = $id_user"; // verifica no banco
$db->setQuery($query);
$user_array = $db->loadObject();
$nome = $user_array->username; /recebe username do array
?>
<?php echo $nome; ?> //print do resultado!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment