Spade

Mini Shell

Directory:~$ /home/lmsyaran/public_html/j3/administrator/components/com_helpdeskpro/libraries/form/field/
Upload File

[Home] [System Details] [Kill Me]
Current File:~$ /home/lmsyaran/public_html/j3/administrator/components/com_helpdeskpro/libraries/form/field/sql.php

<?php
/**
 * Supports an custom SQL select list
 *
 * @package     Joomla.HDP
 * @subpackage  Form
 */

use Joomla\CMS\Factory;

class HDPFormFieldSQL extends HDPFormFieldList
{

	/**
	 * The form field type.
	 *
	 * @var    string
	 */
	protected $type = 'SQL';

	/**
	 * The query.
	 *
	 * @var    string
	 */
	protected $query;

	/**
	 * Method to instantiate the form field object.
	 *
	 * @param   JTable $row   the table object store form field definitions
	 * @param    mixed $value the initial value of the form field
	 *
	 */
	public function __construct($row, $value)
	{
		parent::__construct($row, $value);
		$this->query = $row->values;
	}

	/**
	 * Method to get the custom field options.
	 * Use the query attribute to supply a query to generate the list.
	 *
	 * @return  array  The field option objects.
	 */
	protected function getOptions()
	{
		try
		{
			$db = Factory::getDbo();
			$db->setQuery($this->query);
			$options = $db->loadObjectlist();
		}
		catch (Exception $e)
		{
			$options = array();
		}

		return $options;
	}
}