Last active
July 15, 2016 07:58
-
-
Save AdamMadrzejewski/efa626e744ace977e526 to your computer and use it in GitHub Desktop.
Simple Joomla 3 external script with JSON result from database
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
defined('_JEXEC') or die('Restricted access'); | |
define('DS', DIRECTORY_SEPARATOR); | |
// Use these variables for direct file access | |
// define('_JEXEC', 1); | |
// define('JPATH_BASE', realpath(dirname(__FILE__))); | |
require_once (JPATH_BASE.DS.'includes'.DS.'defines.php'); | |
require_once (JPATH_BASE.DS.'includes'.DS.'framework.php'); | |
$app = JFactory::getApplication('site'); | |
$db = JFactory::getDbo(); | |
$jinput = JFactory::getApplication()->input; | |
$region = $jinput->get('region', 'Abruzzo', 'STRING'); | |
$query = $db->getQuery(true); | |
$query | |
->select($db->qn('id')) | |
->from($db->qn('#__ambulatori_regioni')) | |
->where($db->qn('nome').' = '.$db->q($region)); | |
$db->setQuery($query); | |
$result = $db->loadResult(); | |
echo json_encode($result); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment