<?php
/**
 * Marketplace - Component Marketplace 
 * ******************************************************************
 *
 * PHP version 7.0
 *
 * @category   Component
 * @package    Joomla
 * @author     WebKul software private limited <support@webkul.com>
 * @copyright  2010 WebKul software private limited
 * @license    http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
 * @version    GIT:5.2
 * @filesource http://store.webkul.com
 * @link       Technical Support:  webkul.uvdesk.com
 * ******************************************************************
 */
// no direct access
defined('_JEXEC') or die('Restricted access');
jimport('joomla.database.table');
 
/**
 * MarketplaceTableProducts Table class
 * 
 * @category Component
 * @package  Joomla
 * @author   WebKul software private limited <support@webkul.com>
 * @license  http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
 * @link     Technical Support:  webkul.uvdesk.com
 */
class MarketplaceTableProducts extends JTable
{
    /**
     * Constructor
     *
     * @param object $db connector
     */
    function __construct(&$db) 
    {
        parent::__construct('#__marketplace_product', 'seller_product_id', $db);
    }
    /**
     * Overloaded bind function
     *
     * @param array  $array  var
     * @param string $ignore var
     * 
     * @return void
     */
    public function bind($array, $ignore = '')
    {
        if (isset($array['params']) && is_array($array['params'])) {
            // Convert the params field to a string.
            $parameter = new JRegistry;
            $parameter->loadArray($array['params']);
            $array['params'] = (string)$parameter;
        }
        return parent::bind($array, $ignore);
    }
 
    /**
     * Overloaded load function
     *
     * @param integer $pk    primary key
     * @param boolean $reset var
     * 
     * @return void
     */
    public function load($pk = null, $reset = true) 
    {
        $db=Jfactory::getDbo();
        $obj=(object)$pk;
        try{
            
            $db->select('*');
            $db->from('#__marketplace_product');
        }
        catch(Exception $e){
            $this->setError($e->getMessage());
            return false;
        }
        return true;
    }
    /**
     * Delete function
     *
     * @param [type] $cid var
     * 
     * @return void
     */
    public function delete($cid = null)
    {
        $query = $this->_db->getQuery(true)->delete($this->_tbl);
        $query->where('seller_product_id IN('.implode(',', $cid).')');
        $this->_db->setQuery($query);
        $this->_db->execute();
        return true;
    }
}

