<?php
/**
* @package RSform!Pro
* @copyright (C) 2015 www.rsjoomla.com
* @license GPL, http://www.gnu.org/copyleft/gpl.html
*/

defined('_JEXEC') or die;

use Joomla\CMS\Table\Table;

class TableRSForm_Eway extends Table
{
	public $form_id = null;
	public $merge_vars = '';
	
	public function __construct(& $db) {
		parent::__construct('#__rsform_eway', 'form_id', $db);
	}

	public function check()
	{
		if (is_array($this->merge_vars))
		{
			$this->merge_vars = serialize($this->merge_vars);
		}

		return true;
	}

	public function hasPrimaryKey()
	{
		$db 	= $this->getDbo();
		$key 	= $this->getKeyName();
		$table	= $this->getTableName();

		$query = $db->getQuery(true)
			->select($db->qn($key))
			->from($db->qn($table))
			->where($db->qn($key) . ' = ' . $db->q($this->{$key}));

		return $db->setQuery($query)->loadResult() !== null;
	}
}