OpenCart 🇺🇦

Класс ModelOpenbayEbayProfile extends Model { ... }

Тип Возвр. Описание
public mixed add ( $data )
Исходный код метода:
if($data['default'] == 1) {
	$this->clearDefault($data['type']);
}

$qry = $this->db->query("
	INSERT INTO
		`" . DB_PREFIX . "ebay_profile`
	SET
		`name`          = '".$this->db->escape($data['name'])."',
		`description`   = '".$this->db->escape($data['description'])."',
		`type`          = '".(int)$data['type']."',
		`default`       = '".(int)$data['default']."',
		`data`          = '".$this->db->escape(serialize($data['data']))."'
	");

return $this->db->getLastId();
public mixed edit ( $id, $data )
Исходный код метода:
if($data['default'] == 1) {
	$this->clearDefault($data['type']);
}

$qry = $this->db->query("
	UPDATE
		`" . DB_PREFIX . "ebay_profile`
	SET
		`name`          = '".$this->db->escape($data['name'])."',
		`description`   = '".$this->db->escape($data['description'])."',
		`data`          = '".$this->db->escape(serialize($data['data']))."',
		`default`       = '".(int)$data['default']."'
	WHERE
		`ebay_profile_id` = '".(int)$id."'
	LIMIT 1
	");
public mixed delete ( $id )
Исходный код метода:
$this->db->query("DELETE FROM `" . DB_PREFIX . "ebay_profile` WHERE `ebay_profile_id` = '".(int)$id."' LIMIT 1");

if($this->db->countAffected() > 0) {
	return true;
}else{
	return false;
}
public mixed get ( $id )
Исходный код метода:
$qry = $this->db->query("
	SELECT * FROM
		`" . DB_PREFIX . "ebay_profile`
	WHERE
		`ebay_profile_id` = '".(int)$id."'
	LIMIT 1");

if($qry->num_rows)
{
	$row                = $qry->row;
	$row['link_edit']   = HTTPS_SERVER . 'index.php?route=openbay/ebay_profile/edit&token=' . $this->session->data['token'].'&ebay_profile_id='.$row['ebay_profile_id'];
	$row['link_delete'] = HTTPS_SERVER . 'index.php?route=openbay/ebay_profile/delete&token=' . $this->session->data['token'].'&ebay_profile_id='.$row['ebay_profile_id'];
	$row['data']        = unserialize($row['data']);

	return $row;
}else{
	return false;
}
public mixed getAll ( $type = '' )
Исходный код метода:
$type_sql = '';
if($type !== '') {
	$type_sql = "WHERE `type` = '".(int)$type."'";
}

$qry = $this->db->query("SELECT * FROM `" . DB_PREFIX . "ebay_profile`".$type_sql);

if($qry->num_rows) {
	$profiles = array();
	foreach($qry->rows as $row) {
		$row['link_edit']   = HTTPS_SERVER . 'index.php?route=openbay/ebay_profile/edit&token=' . $this->session->data['token'].'&ebay_profile_id='.$row['ebay_profile_id'];
		$row['link_delete'] = HTTPS_SERVER . 'index.php?route=openbay/ebay_profile/delete&token=' . $this->session->data['token'].'&ebay_profile_id='.$row['ebay_profile_id'];
		$row['data']        = unserialize($row['data']);
		$profiles[]         = $row;
	}

	return $profiles;
}else{
	return false;
}
public mixed getTypes ( )
Исходный код метода:
$types = array(
	0 => array(
		'name'          => 'Shipping',
		'template'      => 'openbay/ebay_profile_form_shipping.tpl'
	),
	1 => array(
		'name'          => 'Returns',
		'template'      => 'openbay/ebay_profile_form_returns.tpl'
	),
	2 => array(
		'name'          => 'Template & gallery',
		'template'      => 'openbay/ebay_profile_form_template.tpl'
	),
	3 => array(
		'name'          => 'General settings',
		'template'      => 'openbay/ebay_profile_form_generic.tpl'
	)
);

return $types;
public mixed getDefault ( $type )
Исходный код метода:
$qry = $this->db->query("
	SELECT `ebay_profile_id` FROM
		`" . DB_PREFIX . "ebay_profile`
	WHERE
		`type` = '".(int)$type."'
	AND
		`default` = '1'
	LIMIT 1");

if($qry->num_rows)
{
	return (int)$qry->row['ebay_profile_id'];
}else{
	return false;
}
private mixed clearDefault ( $type )
Исходный код метода:
$this->db->query("UPDATE `" . DB_PREFIX . "ebay_profile` SET `default` = '0' WHERE `type` = '".(int)$type."'");

Связанные классы:

Название класса Роль
class DB { ... } Компонент Db используется в данном классе
class Session { ... } Компонент Session используется в данном классе

Комментарии