本文整理汇总了PHP中KSSystem::getTableByIds方法的典型用法代码示例。如果您正苦于以下问题:PHP KSSystem::getTableByIds方法的具体用法?PHP KSSystem::getTableByIds怎么用?PHP KSSystem::getTableByIds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KSSystem
的用法示例。
在下文中一共展示了KSSystem::getTableByIds方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getComment
public function getComment()
{
$this->onExecuteBefore('getComment');
$id = JRequest::getInt('id', 0);
$comment = KSSystem::getTableByIds(array($id), 'comments', array('t.id', 't.parent_id', 't.user_id AS user', 't.product_id AS product', 't.name', 't.comment', 't.good', 't.bad', 't.rate', 't.date_add', 't.type'), true, false, true);
if (!empty($comment)) {
$comment->user = KSUsers::getUser($comment->user);
if (isset($comment->product) && $comment->product > 0) {
$comment->product = KSMProducts::getProduct($comment->product);
}
$this->onExecuteAfter('getComment', array(&$comment));
return $comment;
}
return new stdClass();
}
示例2: getProductCategory
function getProductCategory($product_id)
{
$final_categories = array();
$parent_ids = array();
$default_category = $this->getDefaultCategory($product_id);
$product_categories = $this->getProductCategories($product_id);
foreach ($product_categories as $product_category) {
if (!empty($default_category)) {
$id_default_way = false;
} else {
$id_default_way = true;
}
$categories = array();
$parent = $product_category->category_id;
while ($parent != 0) {
if ($parent == $default_category) {
$id_default_way = true;
}
$category = KSSystem::getTableByIds(array($parent), 'categories', array('t.id', 't.parent_id'), true, false, true);
$categories[] = $category->id;
$parent = $category->parent_id;
}
if ($id_default_way && count($categories) > count($final_categories)) {
$final_categories = $categories;
}
}
$category_id = count($final_categories) ? $final_categories[0] : 0;
return $category_id;
}
示例3: updateCart
public function updateCart()
{
$this->onExecuteBefore('updateCart');
$params = JComponentHelper::getParams('com_ksenmart');
$jinput = JFactory::getApplication()->input;
$count = $jinput->get('count', 0, 'float');
$price = $jinput->get('price', 0, 'float');
$item_id = $jinput->get('item_id', 0, 'int');
$item = KSSystem::getTableByIds(array($item_id), 'order_items', array('t.id', 't.order_id', 't.price', 't.count', 't.product_id'), false, false, true);
if ($price != 0 && $price != $item->price) {
$order_item_object = new stdClass();
$order_item_object->id = $item_id;
$order_item_object->price = $price;
$order_item_object->count = $count;
try {
$result = $this->_db->updateObject('#__ksenmart_order_items', $order_item_object, 'id');
} catch (Exception $e) {
}
$diff = ($price - $item->price) * $item->count;
$item->price = $price;
$order_object = new stdClass();
$order_object->id = $item->order_id;
$order_object->cost = $this->getOrderCost($this->order_id) + $diff;
try {
$result = $this->_db->updateObject('#__ksenmart_orders', $order_object, 'id');
} catch (Exception $e) {
}
}
$prd = KSMProducts::getProduct($item->product_id);
$item_properties = array();
foreach ($prd->properties as $property) {
$value = JRequest::getVar('property_' . $property->id, '');
if (!empty($value)) {
$item_properties[] = $property->id . ':' . $value;
}
}
$order_item_object = new stdClass();
$order_item_object->id = $item_id;
$order_item_object->properties = json_encode($item_properties);
try {
$result = $this->_db->updateObject('#__ksenmart_order_items', $order_item_object, 'id');
} catch (Exception $e) {
}
$diff_count = $count - $item->count;
$diff = ($count - $item->count) * $item->price;
if ($count == 0) {
$query = $this->_db->getQuery(true);
$conditions = array('id=' . $this->_db->escape($item_id));
$query->delete(KSDb::quoteName('#__ksenmart_order_items'))->where($conditions);
$this->_db->setQuery($query);
try {
$result = $this->_db->query();
// $this->_db->execute(); for Joomla 3.0.
} catch (Exception $e) {
}
} else {
$order_item_object = new stdClass();
$order_item_object->id = $item_id;
$order_item_object->count = $count;
try {
$result = $this->_db->updateObject('#__ksenmart_order_items', $order_item_object, 'id');
} catch (Exception $e) {
}
}
if ($params->get('use_stock', 1)) {
$product_object = new stdClass();
$product_object->id = $item->product_id;
$product_object->in_stock = $prd->in_stock - $diff_count;
try {
$result = $this->_db->updateObject('#__ksenmart_products', $product_object, 'id');
} catch (Exception $e) {
}
}
$order_object = new stdClass();
$order_object->id = $item->order_id;
$order_object->cost = $this->getOrderCost($item->order_id) + $diff;
try {
$result = $this->_db->updateObject('#__ksenmart_orders', $order_object, 'id');
} catch (Exception $e) {
}
$orderItem = $this->getOrderUpdateItems($item->order_id, $item->id);
$this->onExecuteAfter('updateCart', array(&$orderItem));
return $orderItem;
}
示例4: getWatched
/**
* KsenMartModelProfile::getWatched()
*
* @return
*/
public function getWatched()
{
$this->onExecuteBefore('getWatched');
$user = KSUsers::getUser();
$limitstart = JFactory::getApplication()->input->get('limitstart', 0, 'int');
$rows = KSSystem::getTableByIds($user->watched, 'products', array('t.id'));
if (!empty($rows)) {
foreach ($rows as &$row) {
$row = KSMProducts::getProduct($row->id);
}
$this->_pagination = new JPagination($this->_total, $limitstart, $this->_limit);
}
$this->onExecuteAfter('getWatched', array(&$rows));
return $rows;
}
示例5: getProductTitle
public function getProductTitle()
{
$this->onExecuteBefore('getProductTitle');
$params = JComponentHelper::getParams('com_ksenmart');
$config = KSSystem::getSeoTitlesConfig('product');
$shop_name = $params->get('shop_name', '');
$path_separator = $params->get('path_separator', ' ');
$title = array();
if (empty($this->_product->metatitle)) {
if ($shop_name != '') {
$title[] = $shop_name;
}
foreach ($config as $key => $val) {
if ($val->user == 0) {
if ($val->active == 1) {
if ($key == 'seo-product') {
$title[] = $this->_product->title;
}
if ($key == 'seo-product_code') {
$title[] = $this->_product->product_code;
}
if ($key == 'seo-manufacturer' && isset($this->_product->manufacturer->id)) {
$manufacturer_title = KSSystem::getTableByIds(array($this->_product->manufacturer->id), 'manufacturers', array('t.title'), false, false, true);
$title[] = $manufacturer_title->title;
}
if ($key == 'seo-country' && isset($this->_product->manufacturer->id)) {
if (!empty($this->_product->manufacturer->country)) {
$country_title = KSSystem::getTableByIds(array($this->_product->manufacturer->country->id), 'countries', array('t.title'), false, false, true);
$title[] = $country_title->title;
}
} elseif ($key == 'seo-parent-category') {
$categories = array();
$query = $this->_db->getQuery(true);
$query->select('category_id')->from('#__ksenmart_products_categories')->where('product_id=' . $this->_db->Quote((int) $this->_id))->where('is_default=1');
$this->_db->setQuery($query);
$default_category = $this->_db->loadResult();
$parent = $default_category;
while ($parent != 0) {
$query = $this->_db->getQuery(true);
$query->select('title,parent_id')->from('#__ksenmart_categories')->where('id=' . $this->_db->Quote($parent));
$this->_db->setQuery($query);
$category = $this->_db->loadObject();
if ($category->title != '' && $parent != $default_category) {
$categories[] = $category->title;
}
$parent = $category->parent_id;
}
$categories = array_reverse($categories);
foreach ($categories as $category) {
$title[] = $category;
}
} elseif ($key == 'seo-category') {
$query = $this->_db->getQuery(true);
$query->select('category_id')->from('#__ksenmart_products_categories')->where('product_id=' . $this->_db->Quote((int) $this->_id))->where('is_default=1');
$this->_db->setQuery($query);
$default_category = $this->_db->loadResult();
$query = $this->_db->getQuery(true);
$query->select('title')->from('#__ksenmart_categories')->where('id=' . $this->_db->Quote($default_category));
$this->_db->setQuery($query);
$cat_title = $this->_db->loadResult();
if (!empty($cat_title)) {
$title[] = $cat_title;
}
}
}
} else {
if (strpos($key, 'property_') !== false) {
$property_id = str_replace('property_', '', $key);
if (isset($this->_product->properties[$property_id]->values)) {
$values = array();
foreach ($this->_product->properties[$property_id]->values as $value) {
if ($value->title != '') {
$values[] = $value->title;
}
}
if (count($values) > 0) {
$title[] = $val->title . ' - ' . implode(', ', $values);
}
}
} else {
$title[] = $val->title;
}
}
}
} else {
$title[] = $this->_product->metatitle;
}
$this->onExecuteAfter('getProductTitle', array(&$path_separator, &$title));
return implode($path_separator, $title);
}
示例6: setManufacturerMetaData
/**
* KsenMartModelcatalog::setManufacturerMetaData()
*
* @return
*/
public function setManufacturerMetaData()
{
$this->onExecuteBefore('setManufacturerMetaData');
$document = JFactory::getDocument();
$metatitle = '';
$metadescription = '';
$metakeywords = '';
$manufacturer = $this->getManufacturer();
$config = KSSystem::getSeoTitlesConfig('manufacturer', 'meta');
if (empty($manufacturer->metatitle)) {
$metatitle = $manufacturer->title;
} else {
$metatitle = $manufacturer->metatitle;
}
if (empty($manufacturer->metadescription)) {
if ($config->description->flag == 1) {
if ($config->description->type == 'seo-type-mini-description') {
$metadescription = strip_tags($manufacturer->introcontent);
} elseif ($config->description->type == 'seo-type-description') {
$metadescription = strip_tags($manufacturer->content);
}
$metadescription = mb_substr($metadescription, 0, $config->description->symbols);
}
} else {
$metadescription = $manufacturer->metadescription;
}
if (empty($manufacturer->metakeywords)) {
if ($config->keywords->flag == 1) {
if ($config->keywords->type == 'seo-type-country') {
$countries = KSSystem::getTableByIds(array($manufacturer->country), 'countries', array('t.title'));
if (!empty($countries[0]->title)) {
$metakeywords = $countries[0]->title;
}
} elseif ($config->keywords->type == 'seo-type-title') {
$metakeywords = strip_tags($manufacturer->title);
}
}
} else {
$metakeywords = $manufacturer->metakeywords;
}
if (!empty($metatitle)) {
$document->setMetaData('title', $metatitle);
}
if (!empty($metadescription)) {
$document->setMetaData('description', $metadescription);
}
if (!empty($metakeywords)) {
$document->setMetaData('keywords', $metakeywords);
}
$this->onExecuteAfter('setManufacturerMetaData', array(&$this));
return true;
}