本文整理汇总了PHP中sub_str函数的典型用法代码示例。如果您正苦于以下问题:PHP sub_str函数的具体用法?PHP sub_str怎么用?PHP sub_str使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sub_str函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: get_cat_articles
/**
* 获得文章分类下的文章列表
*
* @access public
* @param integer $cat_id
* @param integer $page
* @param integer $size
*
* @return array
*/
function get_cat_articles($cat_id, $page = 1, $size = 20, $requirement = '')
{
//取出所有非0的文章
if ($cat_id == '-1') {
$cat_str = 'cat_id > 0';
} else {
$cat_str = get_article_children($cat_id);
}
//增加搜索条件,如果有搜索内容就进行搜索
if ($requirement != '') {
$sql = 'SELECT article_id, title, author, add_time, file_url, open_type' . ' FROM ' . $GLOBALS['ecs']->table('ecsmart_article') . ' WHERE is_open = 1 AND title like \'%' . $requirement . '%\' ' . ' ORDER BY article_type DESC, article_id DESC';
} else {
$sql = 'SELECT article_id, title, author, add_time, file_url, open_type' . ' FROM ' . $GLOBALS['ecs']->table('ecsmart_article') . ' WHERE is_open = 1 AND ' . $cat_str . ' ORDER BY article_type DESC, article_id DESC';
}
$res = $GLOBALS['db']->selectLimit($sql, $size, ($page - 1) * $size);
$arr = array();
if ($res) {
while ($row = $GLOBALS['db']->fetchRow($res)) {
$article_id = $row['article_id'];
$arr[$article_id]['id'] = $article_id;
$arr[$article_id]['title'] = $row['title'];
$arr[$article_id]['short_title'] = $GLOBALS['_CFG']['article_title_length'] > 0 ? sub_str($row['title'], $GLOBALS['_CFG']['article_title_length']) : $row['title'];
$arr[$article_id]['author'] = empty($row['author']) || $row['author'] == '_SHOPHELP' ? $GLOBALS['_CFG']['shop_name'] : $row['author'];
$arr[$article_id]['url'] = $row['open_type'] != 1 ? build_uri('article', array('aid' => $article_id), $row['title']) : trim($row['file_url']);
$arr[$article_id]['add_time'] = date($GLOBALS['_CFG']['date_format'], $row['add_time']);
}
}
return $arr;
}
开发者ID:seanguo166,项目名称:yinoos,代码行数:39,代码来源:lib_article.php
示例2: insert_history
/**
* 调用浏览历史
*
* @access public
* @return string
*/
function insert_history()
{
$time = gmtime();
$str = '';
if (!empty($_COOKIE['ECS']['history'])) {
$where = db_create_in($_COOKIE['ECS']['history'], 'goods_id');
$sql = 'SELECT goods_id, goods_name, goods_thumb, shop_price ,promote_price,promote_start_date,promote_end_date,is_promote FROM ' . $GLOBALS['ecs']->table('goods') . " WHERE {$where} AND is_on_sale = 1 AND is_alone_sale = 1 AND is_delete = 0";
$query = $GLOBALS['db']->query($sql);
$res = array();
while ($row = $GLOBALS['db']->fetch_array($query)) {
$goods['goods_id'] = $row['goods_id'];
$goods['goods_name'] = $row['goods_name'];
$goods['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
$goods['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);
if ($row['is_promote'] == 1 && $time > $row['promote_start_date'] && $time < $row['promote_end_date']) {
$goods['shop_price'] = price_format($row['promote_price']);
} else {
$goods['shop_price'] = price_format($row['shop_price']);
}
$goods['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']);
$str .= '<ul class="clearfix"><li class="goodsimg"><a href="' . $goods['url'] . '" target="_blank"><img src="' . $goods['goods_thumb'] . '" alt="' . $goods['goods_name'] . '" class="B_blue" /></a></li><li><a href="' . $goods['url'] . '" target="_blank" title="' . $goods['goods_name'] . '">' . $goods['short_name'] . '</a><br />' . $GLOBALS['_LANG']['shop_price'] . '<font class="f1">' . $goods['shop_price'] . '</font><br /></li></ul>';
}
$str .= '<ul id="clear_history"><a onclick="clear_history()">' . $GLOBALS['_LANG']['clear_history'] . '</a></ul>';
}
return $str;
}
开发者ID:hackjiyi,项目名称:maozishifa,代码行数:32,代码来源:lib_insert.php
示例3: get_supplier_goods
function get_supplier_goods($gtype = 0, $limit = 10)
{
$gtype = intval($gtype);
if ($gtype <= 0) {
return;
}
$sql = "SELECT DISTINCT g.goods_id,g.* FROM " . $GLOBALS['ecs']->table('goods') . " AS g, " . $GLOBALS['ecs']->table('supplier_goods_cat') . " AS gc, " . $GLOBALS['ecs']->table('supplier_cat_recommend') . " AS cr \n\tWHERE cr.recommend_type =" . $gtype . " AND cr.supplier_id =" . $_GET['suppId'] . " AND cr.cat_id = gc.cat_id AND gc.goods_id = g.goods_id \n\tAND g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 \n\tORDER BY g.sort_order, g.last_update DESC LIMIT " . $limit;
$result = $GLOBALS['db']->getAll($sql);
$goods = array();
if ($result) {
foreach ($result as $idx => $row) {
if ($row['promote_price'] > 0) {
$promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']);
$goods[$idx]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : '';
} else {
$goods[$idx]['promote_price'] = '';
}
$goods[$idx]['id'] = $row['goods_id'];
$goods[$idx]['name'] = $row['goods_name'];
$goods[$idx]['brief'] = $row['goods_brief'];
$goods[$idx]['brand_name'] = isset($goods_data['brand'][$row['goods_id']]) ? $goods_data['brand'][$row['goods_id']] : '';
$goods[$idx]['goods_style_name'] = add_style($row['goods_name'], $row['goods_name_style']);
$goods[$idx]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
$goods[$idx]['short_style_name'] = add_style($goods[$idx]['short_name'], $row['goods_name_style']);
$goods[$idx]['market_price'] = price_format($row['market_price']);
$goods[$idx]['shop_price'] = price_format($row['shop_price']);
$goods[$idx]['thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);
$goods[$idx]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']);
//$goods[$idx]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']);
}
}
return $goods;
}
开发者ID:firsteam,项目名称:falcons,代码行数:33,代码来源:supplier_index.php
示例4: brand_get_goodsex
function brand_get_goodsex($brand_id, $cate, $size, $page, $sort, $order)
{
$cate_where = 0 < $cate ? "AND " . get_children($cate) : "";
$sql = "SELECT g.goods_id, g.goods_name, g.goods_sn, g.market_price, g.shop_price AS org_price,g.is_promote, g.is_new, g.is_best, g.is_hot," . ("IFNULL(mp.user_price, g.shop_price * '" . $_SESSION['discount'] . "') AS shop_price, g.promote_price, ") . "(select AVG(r.comment_rank) from " . $GLOBALS['ecs']->table("comment") . " as r where r.id_value = g.goods_id AND r.comment_type = 0 AND r.parent_id = 0 AND r.status = 1) AS comment_rank, (select IFNULL(sum(r.id_value), 0) from " . $GLOBALS['ecs']->table("comment") . " as r where r.id_value = g.goods_id AND r.comment_type = 0 AND r.parent_id = 0 AND r.status = 1) AS comment_count, (select IFNULL(sum(og.goods_number), 0) from " . $GLOBALS['ecs']->table("order_goods") . " as og where og.goods_id = g.goods_id) AS sell_number, g.promote_start_date, g.promote_end_date, g.goods_brief, g.goods_thumb , g.goods_img FROM " . $GLOBALS['ecs']->table("goods") . " AS g LEFT JOIN " . $GLOBALS['ecs']->table("member_price") . " AS mp " . ("ON mp.goods_id = g.goods_id AND mp.user_rank = '" . $_SESSION['user_rank'] . "' ") . ("WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 AND g.brand_id = '" . $brand_id . "' {$cate_where}") . ("ORDER BY " . $sort . " {$order}");
$res = $GLOBALS['db']->selectLimit($sql, $size, ($page - 1) * $size);
$arr = array();
while ($row = $GLOBALS['db']->fetchRow($res)) {
if (0 < $row['promote_price']) {
$promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']);
} else {
$promote_price = 0;
}
$arr[$row['goods_id']]['goods_id'] = $row['goods_id'];
if ($GLOBALS['display'] == "grid") {
$arr[$row['goods_id']]['short_name'] = 0 < $GLOBALS['_CFG']['goods_name_length'] ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
}
$arr[$row['goods_id']]['goods_name'] = $row['goods_name'];
$arr[$row['goods_id']]['goods_sn'] = $row['goods_sn'];
$arr[$row['goods_id']]['comment_count'] = $row['comment_count'];
$arr[$row['goods_id']]['comment_rank'] = $row['comment_rank'];
$arr[$row['goods_id']]['sell_number'] = $row['sell_number'];
$arr[$row['goods_id']]['is_promote'] = $row['is_promote'];
$arr[$row['goods_id']]['is_new'] = $row['is_new'];
$arr[$row['goods_id']]['is_best'] = $row['is_best'];
$arr[$row['goods_id']]['is_hot'] = $row['is_hot'];
$arr[$row['goods_id']]['market_price'] = price_format($row['market_price']);
$arr[$row['goods_id']]['shop_price'] = price_format($row['shop_price']);
$arr[$row['goods_id']]['promote_price'] = 0 < $promote_price ? price_format($promote_price) : "";
$arr[$row['goods_id']]['goods_brief'] = $row['goods_brief'];
$arr[$row['goods_id']]['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], TRUE);
$arr[$row['goods_id']]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']);
$arr[$row['goods_id']]['url'] = build_uri("goods", array("gid" => $row['goods_id']), $row['goods_name']);
}
return $arr;
}
开发者ID:firsteam,项目名称:falcons,代码行数:35,代码来源:brand.php
示例5: get_index_best
/**
* 获得推荐商品
*
* @access public
* @param string $type 推荐类型,可以是 best, new, hot
* @return array
*/
function get_index_best($limit = '')
{
$time = gmtime();
//取出所有符合条件的商品数据,并将结果存入对应的推荐类型数组中
$sql = 'SELECT g.goods_id, g.goods_name,g.click_count, g.goods_name_style, g.market_price, g.shop_price AS org_price, g.promote_price, ' . "IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price, " . "promote_start_date, promote_end_date, g.goods_brief, g.goods_thumb, g.goods_img, RAND() AS rnd " . 'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' . "LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp " . "ON mp.goods_id = g.goods_id AND mp.user_rank = '{$_SESSION['user_rank']}' ";
$sql .= ' WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 AND g.is_best = "best" ';
$sql .= ' ORDER BY g.sort_order, g.last_update DESC';
$sql .= " {$limit}";
$result = $GLOBALS['db']->getAll($sql);
foreach ($result as $idx => $row) {
if ($row['promote_price'] > 0) {
$promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']);
$goods[$idx]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : '';
} else {
$goods[$idx]['promote_price'] = '';
}
$goods[$idx]['id'] = $row['goods_id'];
$goods[$idx]['name'] = $row['goods_name'];
$goods[$idx]['brief'] = $row['goods_brief'];
$goods[$idx]['brand_name'] = isset($goods_data['brand'][$row['goods_id']]) ? $goods_data['brand'][$row['goods_id']] : '';
$goods[$idx]['goods_style_name'] = add_style($row['goods_name'], $row['goods_name_style']);
$goods[$idx]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
$goods[$idx]['short_style_name'] = add_style($goods[$idx]['short_name'], $row['goods_name_style']);
$goods[$idx]['market_price'] = price_format($row['market_price']);
$goods[$idx]['shop_price'] = price_format($row['shop_price']);
$goods[$idx]['thumb'] = '../' . get_image_path($row['goods_id'], $row['goods_thumb'], true);
$goods[$idx]['goods_img'] = '../' . get_image_path($row['goods_id'], $row['goods_img']);
$goods[$idx]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']);
$goods[$idx]['sell_count'] = selled_count($row['goods_id']);
$goods[$idx]['pinglun'] = get_evaluation_sum($row['goods_id']);
$goods[$idx]['count'] = selled_count($row['goods_id']);
$goods[$idx]['click_count'] = $row['click_count'];
}
return $goods;
}
开发者ID:firsteam,项目名称:falcons,代码行数:42,代码来源:index_bestgoods.php
示例6: get_cat_id_goods_list
function get_cat_id_goods_list($cat_id = '', $num = '', $ext = '')
{
$sql = 'Select g.goods_id,g.guige, g.cat_id,c.parent_id, g.goods_name, g.goods_number, g.goods_name_style, g.market_price, g.shop_price AS org_price, g.promote_price, ' . "IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price, " . "promote_start_date, promote_end_date, g.goods_brief, g.goods_thumb, goods_img, " . "g.is_best, g.is_new, g.is_hot, g.is_promote,b.brand_name " . 'FROM ' . $GLOBALS['hhs']->table('goods') . ' AS g ' . 'LEFT JOIN ' . $GLOBALS['hhs']->table('category') . ' AS c ON c.cat_id = g.cat_id ' . "LEFT JOIN " . $GLOBALS['hhs']->table('member_price') . " AS mp " . "ON mp.goods_id = g.goods_id AND mp.user_rank = '{$_SESSION['user_rank']}' " . " left join " . $GLOBALS['hhs']->table('brand') . " as b on g.brand_id=b.brand_id " . " Where g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_new = 1 AND g.is_delete = 0 and g.is_mall=1 " . ($sql .= " AND (c.parent_id =" . $cat_id . " OR g.cat_id = " . $cat_id . " OR g.cat_id " . db_create_in(array_unique(array_merge(array($cat_id), array_keys(cat_list($cat_id, 0, false))))) . ")");
$sql .= $ext;
$sql .= " LIMIT {$num}";
$res = $GLOBALS['db']->getAll($sql);
$goods = array();
foreach ($res as $idx => $row) {
$goods[$idx]['id'] = $row['goods_id'];
$goods[$idx]['name'] = $row['goods_name'];
$goods[$idx]['guige'] = $row['guige'];
$goods[$idx]['brief'] = $row['goods_brief'];
$goods[$idx]['brand_name'] = $row['brand_name'];
$goods[$idx]['goods_number'] = $row['goods_number'];
$goods[$idx]['goods_style_name'] = add_style($row['goods_name'], $row['goods_name_style']);
$goods[$idx]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
$goods[$idx]['short_style_name'] = add_style($goods[$idx]['short_name'], $row['goods_name_style']);
$goods[$idx]['market_price'] = price_format($row['market_price']);
$goods[$idx]['shop_price'] = price_format($row['shop_price']);
$goods[$idx]['thumb'] = empty($row['goods_thumb']) ? $GLOBALS['_CFG']['no_picture'] : $row['goods_thumb'];
$goods[$idx]['goods_img'] = empty($row['goods_img']) ? $GLOBALS['_CFG']['no_picture'] : $row['goods_img'];
$goods[$idx]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']);
if ($GLOBALS['SID']) {
$goods[$idx]['shop_price'] = price_format($row['s_goods_price']);
}
}
return $goods;
}
开发者ID:shiruolin,项目名称:hzzshop,代码行数:28,代码来源:index.php
示例7: add_feed
/**
* 通过判断is_feed 向UCenter提交Feed
*
* @access public
* @param integer $value_id $order_id or $comment_id
* @param interger $feed_type BUY_GOODS or COMMENT_GOODS
*
* @return void
*/
function add_feed($id, $feed_type)
{
$feed = array();
if ($feed_type == BUY_GOODS) {
if (empty($id)) {
return;
}
$id = intval($id);
$order_res = $GLOBALS['db']->getAll("SELECT g.goods_id, g.goods_name, g.goods_sn, g.goods_desc, g.goods_thumb, o.goods_price FROM " . $GLOBALS['ecs']->table('order_goods') . " AS o, " . $GLOBALS['ecs']->table('goods') . " AS g WHERE o.order_id='{$id}' AND o.goods_id=g.goods_id");
foreach ($order_res as $goods_data) {
if (!empty($goods_data['goods_thumb'])) {
$url = $GLOBALS['ecs']->url() . $goods_data['goods_thumb'];
} else {
$url = $GLOBALS['ecs']->url() . $GLOBALS['_CFG']['no_picture'];
}
$link = $GLOBALS['ecs']->url() . "goods.php?id=" . $goods_data["goods_id"];
$feed['icon'] = "goods";
$feed['title_template'] = '<b>{username} ' . $GLOBALS['_LANG']['feed_user_buy'] . ' {goods_name}</b>';
$feed['title_data'] = array('username' => $_SESSION['user_name'], 'goods_name' => $goods_data['goods_name']);
$feed['body_template'] = '{goods_name} ' . $GLOBALS['_LANG']['feed_goods_price'] . ':{goods_price} ' . $GLOBALS['_LANG']['feed_goods_desc'] . ':{goods_desc}';
$feed['body_data'] = array('goods_name' => $goods_data['goods_name'], 'goods_price' => $goods_data['goods_price'], 'goods_desc' => sub_str(strip_tags($goods_data['goods_desc']), 150, true));
$feed['images'][] = array('url' => $url, 'link' => $link);
uc_call("uc_feed_add", array($feed['icon'], $_SESSION['user_id'], $_SESSION['user_name'], $feed['title_template'], $feed['title_data'], $feed['body_template'], $feed['body_data'], '', '', $feed['images']));
}
}
return;
}
开发者ID:seanguo166,项目名称:yinoos,代码行数:36,代码来源:lib_uc.php
示例8: insert_cart_info
/**
* 调用购物车信息
*
* @access public
* @return string
*/
function insert_cart_info()
{
$sql = 'SELECT c.*,g.goods_name,g.goods_thumb,g.goods_id,c.goods_number,c.goods_price' . ' FROM ' . $GLOBALS['ecs']->table('cart') . " AS c " . " LEFT JOIN " . $GLOBALS['ecs']->table('goods') . " AS g ON g.goods_id=c.goods_id " . " WHERE session_id = '" . SESS_ID . "' AND rec_type = '" . CART_GENERAL_GOODS . "'";
$row = $GLOBALS['db']->GetAll($sql);
$arr = array();
foreach ($row as $k => $v) {
$arr[$k]['goods_thumb'] = get_image_path($v['goods_id'], $v['goods_thumb'], true);
$arr[$k]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($v['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $v['goods_name'];
$arr[$k]['url'] = build_uri('goods', array('gid' => $v['goods_id']), $v['goods_name']);
$arr[$k]['goods_number'] = $v['goods_number'];
$arr[$k]['goods_name'] = $v['goods_name'];
$arr[$k]['goods_price'] = price_format($v['goods_price']);
$arr[$k]['rec_id'] = $v['rec_id'];
}
$sql = 'SELECT SUM(goods_number) AS number, SUM(goods_price * goods_number) AS amount' . ' FROM ' . $GLOBALS['ecs']->table('cart') . " WHERE session_id = '" . SESS_ID . "' AND rec_type = '" . CART_GENERAL_GOODS . "'";
$row = $GLOBALS['db']->GetRow($sql);
if ($row) {
$number = intval($row['number']);
$amount = floatval($row['amount']);
} else {
$number = 0;
$amount = 0;
}
$GLOBALS['smarty']->assign('str', sprintf($GLOBALS['_LANG']['cart_info'], $number, price_format($amount, false)));
$GLOBALS['smarty']->assign('goods', $arr);
$output = $GLOBALS['smarty']->fetch('library/cart_info.lbi');
return $output;
}
开发者ID:a494008974,项目名称:bzbshop,代码行数:34,代码来源:lib_insert.php
示例9: get_cat_articles
/**
* 获得文章分类下的文章列表
*
* @access public
* @param integer $cat_id
* @param integer $page
* @param integer $size
* @return array
*/
public function get_cat_articles($cat_id, $page = 1, $size = 20, $requirement = '')
{
// 取出所有非0的文章
if ($cat_id == '-1') {
$cat_str = 'cat_id > 0';
} else {
$cat_str = get_article_children($cat_id);
}
$condition = 'is_open = 1 AND ' . $cat_str;
// 增加搜索条件,如果有搜索内容就进行搜索
if ($requirement != '') {
$condition .= ' AND title like \'%' . $requirement . '%\'';
}
$limit = ($page - 1) * $size . ',' . $size;
$list = $this->select($condition, 'article_id, title, author, add_time, file_url, open_type,link', ' article_id DESC', $limit);
$i = 1;
$arr = array();
if (is_array($list)) {
foreach ($list as $vo) {
$article_id = $vo['article_id'];
$arr[$article_id]['id'] = $article_id;
$arr[$article_id]['index'] = $i;
$arr[$article_id]['title'] = $vo['title'];
$arr[$article_id]['short_title'] = C('article_title_length') > 0 ? sub_str($vo['title'], C('article_title_length')) : $vo['title'];
$arr[$article_id]['author'] = empty($vo['author']) || $vo['author'] == '_SHOPHELP' ? C('shop_name') : $vo['author'];
$arr[$article_id]['url'] = $vo['link'] ? $vo['link'] : url('article/info', array('aid' => $article_id));
$arr[$article_id]['add_time'] = date(C('date_format'), $vo['add_time']);
$i++;
}
}
return $arr;
}
开发者ID:ChanHarold,项目名称:ecshop,代码行数:41,代码来源:ArticleBaseModel.class.php
示例10: brand_get_goodsex
function brand_get_goodsex($brand_id, $cate, $size, $page, $sort, $order)
{
$cate_where = $cate > 0 ? 'AND ' . get_children($cate) : '';
/* 获得商品列表 */
$sql = 'SELECT g.goods_id, g.goods_name, g.goods_sn, g.market_price, g.shop_price AS org_price, g.is_new,' . "IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price, g.promote_price, " . '(select AVG(r.comment_rank) from ' . $GLOBALS['ecs']->table('comment') . ' as r where r.id_value = g.goods_id AND r.comment_type = 0 AND r.parent_id = 0 AND r.status = 1) AS comment_rank, ' . '(select IFNULL(sum(og.goods_number), 0) from ' . $GLOBALS['ecs']->table('order_goods') . ' as og where og.goods_id = g.goods_id) AS sell_number, ' . 'g.promote_start_date, g.promote_end_date, g.goods_brief, g.goods_thumb , g.goods_img ' . 'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('member_price') . ' AS mp ' . "ON mp.goods_id = g.goods_id AND mp.user_rank = '{$_SESSION['user_rank']}' " . "WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 AND g.brand_id = '{$brand_id}' {$cate_where}" . "ORDER BY {$sort} {$order}";
$res = $GLOBALS['db']->selectLimit($sql, $size, ($page - 1) * $size);
$arr = array();
while ($row = $GLOBALS['db']->fetchRow($res)) {
if ($row['promote_price'] > 0) {
$promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']);
} else {
$promote_price = 0;
}
$arr[$row['goods_id']]['goods_id'] = $row['goods_id'];
if ($GLOBALS['display'] == 'grid') {
$arr[$row['goods_id']]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
}
$arr[$row['goods_id']]['goods_name'] = $row['goods_name'];
$arr[$row['goods_id']]['goods_sn'] = $row['goods_sn'];
$arr[$row['goods_id']]['comment_rank'] = $row['comment_rank'];
$arr[$row['goods_id']]['sell_number'] = $row['sell_number'];
$arr[$row['goods_id']]['is_new'] = $row['is_new'];
$arr[$row['goods_id']]['market_price'] = price_format($row['market_price']);
$arr[$row['goods_id']]['shop_price'] = price_format($row['shop_price']);
$arr[$row['goods_id']]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : '';
$arr[$row['goods_id']]['goods_brief'] = $row['goods_brief'];
$arr[$row['goods_id']]['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);
$arr[$row['goods_id']]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']);
$arr[$row['goods_id']]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']);
}
return $arr;
}
开发者ID:qgz,项目名称:ecshop,代码行数:32,代码来源:brand.php
示例11: show_chooseform
function show_chooseform()
{
echo "\t\t<script language=\"JavaScript\" type=\"text/javascript\">\n";
echo "\t\t<!--\n";
echo "\t\tdocument.forms['payform'].js.value=1;\n";
echo "\t\t-->;\n";
echo "\t\t</script>\n";
echo "\t\t<script language='javascript' type='text/javascript' src='https://secure.payu.com/paygw/UTF/js/" . $this->pos . "/" . sub_str($this->key1, 0, 2) . "/template:3/ext_calc:1/paytype.js'></script>\n";
echo "\t\t<script language='JavaScript' type='text/JavaScript'>\n\t\t\t\t\t\t\t\t\t\tPlnPrintTemplate();\n\t\t\t\t\t\t\t\t\t</script>\n";
}
开发者ID:janda2,项目名称:Fitness-shop,代码行数:10,代码来源:class_payu.php
示例12: exchange_get_goods
/**
* 获得分类下的商品
*
* @access public
* @param string $children
* @return array
*/
function exchange_get_goods($children, $min, $max, $ext, $size, $page, $sort, $order) {
$display = $GLOBALS['display'];
$where = "eg.is_exchange = 1 AND g.is_delete = 0 AND " .
"($children OR " . model('Goods')->get_extension_goods($children) . ')';
if ($min > 0) {
$where .= " AND eg.exchange_integral >= $min ";
}
if ($max > 0) {
$where .= " AND eg.exchange_integral <= $max ";
}
/* 获得商品列表 */
$start = ($page - 1) * $size;
$sort = $sort =='sales_volume'? 'xl.sales_volume': $sort;
$sql = 'SELECT g.goods_id, g.goods_name, g.market_price, g.goods_name_style, eg.exchange_integral, ' .
'g.goods_type, g.goods_brief, g.goods_thumb , g.goods_img, eg.is_hot ' .
'FROM ' . $this->pre . 'exchange_goods AS eg LEFT JOIN ' . $this->pre . 'goods AS g ' .
'ON eg.goods_id = g.goods_id ' . ' LEFT JOIN ' . $this->pre . 'touch_goods AS xl ' . ' ON g.goods_id=xl.goods_id ' .
" WHERE $where $ext ORDER BY $sort $order LIMIT $start ,$size ";
$res = $this->query($sql);
$arr = array();
foreach ($res as $row) {
$arr[$row['goods_id']]['goods_id'] = $row['goods_id'];
if ($display == 'grid') {
$arr[$row['goods_id']]['goods_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
} else {
$arr[$row['goods_id']]['goods_name'] = $row['goods_name'];
}
$arr[$row['goods_id']]['name'] = $row['goods_name'];
$arr[$row['goods_id']]['goods_brief'] = $row['goods_brief'];
$arr[$row['goods_id']]['goods_style_name'] = add_style($row['goods_name'], $row['goods_name_style']);
$arr[$row['goods_id']] ['market_price'] = price_format($row ['market_price']);
$arr[$row['goods_id']]['exchange_integral'] = $row['exchange_integral'];
$arr[$row['goods_id']]['type'] = $row['goods_type'];
$arr[$row['goods_id']]['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);
$arr[$row['goods_id']]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']);
$arr[$row['goods_id']]['url'] = build_uri('exchange_goods', array('gid' => $row['goods_id']), $row['goods_name']);
$arr[$row['goods_id']]['sc'] = model('GoodsBase')->get_goods_collect($row['goods_id']);
$arr[$row['goods_id']]['mysc'] = 0;
// 检查是否已经存在于用户的收藏夹
if ($_SESSION ['user_id']) {
unset($where);
// 用户自己有没有收藏过
$where['goods_id'] = $row ['goods_id'];
$where['user_id'] = $_SESSION ['user_id'];
$rs = $this->model->table('collect_goods')->where($where)->count();
$arr[$row['goods_id']]['mysc'] = $rs;
}
}
return $arr;
}
开发者ID:sayi21cn,项目名称:ecshopAndEctouch,代码行数:60,代码来源:ExchangeModel.class.php
示例13: brand_get_goods
/**
* 获得品牌下的商品
*
* @access private
* @param integer $brand_id
* @return array
*/
function brand_get_goods($brand_id, $cate, $sort, $order, $size, $page) {
$cate_where = ($cate > 0) ? 'AND ' . get_children($cate) : '';
$start = ($page - 1) * $size;
/* 获得商品列表 */
$sort = $sort =='sales_volume'? 'xl.sales_volume': $sort;
$sql = 'SELECT g.goods_id, g.goods_name,g.goods_number, g.market_price, g.shop_price AS org_price, ' . "IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS shop_price, g.promote_price, " . 'g.promote_start_date, g.promote_end_date, g.goods_brief, g.goods_thumb , g.goods_img ' . 'FROM ' . $this->pre . 'goods AS g ' . 'LEFT JOIN ' . $this->pre . 'touch_goods AS xl ' . "ON g.goods_id=xl.goods_id " . 'LEFT JOIN ' . $this->pre . 'member_price AS mp ' . "ON mp.goods_id = g.goods_id AND mp.user_rank = '$_SESSION[user_rank]' " . "WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 AND g.brand_id = '$brand_id' $cate_where" . "ORDER BY $sort $order LIMIT $start , $size";
$res = $this->query($sql);
$arr = array();
foreach ($res as $row) {
if ($row['promote_price'] > 0) {
$promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']);
} else {
$promote_price = 0;
}
$arr[$row['goods_id']]['goods_id'] = $row['goods_id'];
if ($GLOBALS['display'] == 'grid') {
$arr[$row['goods_id']]['goods_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
} else {
$arr[$row['goods_id']]['goods_name'] = $row['goods_name'];
}
$arr[$row['goods_id']]['discount'] = $row['market_price'] > 0 ? (round((($promote_price > 0 ? $promote_price : $row['shop_price']) / $row['market_price']) * 10)) : 0;
$arr[$row['goods_id']]['goods_number'] = $row['goods_number'];
$arr[$row['goods_id']]['market_price'] = price_format($row['market_price']);
$arr[$row['goods_id']]['shop_price'] = price_format($row['shop_price']);
$arr[$row['goods_id']]['promote_price'] = ($promote_price > 0) ? price_format($promote_price) : '';
$arr[$row['goods_id']]['goods_brief'] = $row['goods_brief'];
$arr[$row['goods_id']]['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);
$arr[$row['goods_id']]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']);
$arr[$row['goods_id']]['url'] = build_uri('goods/index', array(
'id' => $row['goods_id']
), $row['goods_name']);
$arr[$row['goods_id']]['sales_count'] = model('GoodsBase')->get_sales_count($row['goods_id']);
$arr[$row['goods_id']]['sc'] = model('GoodsBase')->get_goods_collect($row['goods_id']);
$arr[$row['goods_id']]['promotion'] = model('GoodsBase')->get_promotion_show($row['goods_id']);
$arr[$row['goods_id']]['mysc'] = 0;
// 检查是否已经存在于用户的收藏夹
if ($_SESSION['user_id']) {
unset($where);
// 用户自己有没有收藏过
$where['goods_id'] = $row['goods_id'];
$where['user_id'] = $_SESSION['user_id'];
$rs = $this->model->table('collect_goods')
->where($where)
->count();
$arr[$row['goods_id']]['mysc'] = $rs;
}
}
return $arr;
}
开发者ID:sayi21cn,项目名称:ecshopAndEctouch,代码行数:59,代码来源:BrandModel.class.php
示例14: format_content
function format_content($input, $length)
{
if (strlen($input) <= $length) {
return $input;
}
$first = sub_str($input, 0, $length);
if (strlen($input) <= $length * 2) {
$last = sub_str($input, $length);
} else {
$last = sub_str($input, $length, $length - 3) . '...';
}
return "{$first}<br />{$last}";
}
开发者ID:Emon0526,项目名称:zhuoying-wx,代码行数:13,代码来源:function.php
示例15: get_shop_help
/**
* 分配帮助信息
*
* @access public
* @return array
*/
function get_shop_help()
{
$sql = 'SELECT c.cat_id, c.cat_name, c.sort_order, a.article_id, a.title, a.file_url, a.open_type ' . 'FROM ' . $this->pre . 'article AS a ' . 'LEFT JOIN ' . $this->pre . 'article_cat AS c ' . 'ON a.cat_id = c.cat_id WHERE c.cat_type = 5 AND a.is_open = 1 ' . 'ORDER BY c.sort_order ASC, a.article_id';
$res = $this->query($sql);
$arr = array();
foreach ($res as $key => $row) {
$arr[$row['cat_id']]['cat_id'] = build_uri('article_cat', array('acid' => $row['cat_id']), $row['cat_name']);
$arr[$row['cat_id']]['cat_name'] = $row['cat_name'];
$arr[$row['cat_id']]['article'][$key]['article_id'] = $row['article_id'];
$arr[$row['cat_id']]['article'][$key]['title'] = $row['title'];
$arr[$row['cat_id']]['article'][$key]['short_title'] = C('article_title_length') > 0 ? sub_str($row['title'], C('article_title_length')) : $row['title'];
$arr[$row['cat_id']]['article'][$key]['url'] = $row['open_type'] != 1 ? build_uri('article', array('aid' => $row['article_id']), $row['title']) : trim($row['file_url']);
}
return $arr;
}
开发者ID:m7720647,项目名称:demo,代码行数:21,代码来源:ArticleModel.class.php
示例16: get_articles_cat_name
function get_articles_cat_name($cat_name, $limit)
{
$sql = 'SELECT a.article_id, a.title, ac.cat_name, a.add_time, a.file_url, a.open_type, ac.cat_id, ac.cat_name ' . ' FROM ' . $GLOBALS['ecs']->table('article') . ' AS a, ' . $GLOBALS['ecs']->table('article_cat') . ' AS ac' . ' WHERE a.is_open = 1 AND a.cat_id = ac.cat_id AND ac.cat_type = 1 AND ac.cat_name="' . $cat_name . '" ORDER BY a.article_type DESC, a.add_time DESC LIMIT ' . $limit;
$res = $GLOBALS['db']->getAll($sql);
$arr = array();
foreach ($res as $idx => $row) {
$arr[$idx]['id'] = $row['article_id'];
$arr[$idx]['title'] = $row['title'];
$arr[$idx]['short_title'] = $GLOBALS['_CFG']['article_title_length'] > 0 ? sub_str($row['title'], $GLOBALS['_CFG']['article_title_length']) : $row['title'];
$arr[$idx]['cat_name'] = $row['cat_name'];
$arr[$idx]['add_time'] = local_date($GLOBALS['_CFG']['date_format'], $row['add_time']);
$arr[$idx]['url'] = $row['open_type'] != 1 ? build_uri('article', array('aid' => $row['article_id']), $row['title']) : trim($row['file_url']);
$arr[$idx]['cat_url'] = build_uri('article_cat', array('acid' => $row['cat_id']), $row['cat_name']);
}
return $arr;
}
开发者ID:norain2050,项目名称:benhu,代码行数:16,代码来源:lib_common.php
示例17: get_flash_sale_goods
/**
* 获得促销商品
*
* @access public
* @return array
*/
function get_flash_sale_goods($cats = '')
{
$time = gmtime();
$order_type = $GLOBALS['_CFG']['recommend_order'];
/* 取得促销lbi的数量限制 */
$num = get_library_number("recommend_promotion");
$sql = 'SELECT g.goods_id, g.goods_name, g.goods_name_style, g.market_price, g.shop_price AS org_price, g.promote_price, ' . "IFNULL(mp.user_price, g.shop_price * '{$_SESSION['discount']}') AS shop_price, " . "promote_start_date, promote_end_date, g.goods_brief, g.goods_thumb, goods_img, b.brand_name, " . "g.is_best, g.is_new, g.is_hot, g.is_promote, RAND() AS rnd " . 'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('brand') . ' AS b ON b.brand_id = g.brand_id ' . "LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp " . "ON mp.goods_id = g.goods_id AND mp.user_rank = '{$_SESSION['user_rank']}' " . 'WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 ' . " AND g.is_promote = 1 AND promote_start_date <= '{$time}' AND promote_end_date >= '{$time}' ";
$sql .= $order_type == 0 ? ' ORDER BY g.sort_order, g.last_update DESC' : ' ORDER BY rnd';
$result = $GLOBALS['db']->getAll($sql);
$goods = array();
foreach ($result as $idx => $row) {
if ($row['promote_price'] > 0) {
$promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']);
$goods[$idx]['promote_price'] = $promote_price > 0 ? $promote_price : '';
} else {
$goods[$idx]['promote_price'] = '';
}
$sql = 'SELECT sum(goods_number) AS goods_number FROM ' . $GLOBALS['ecs']->table('order_goods') . ' WHERE goods_id =' . $row['goods_id'] . ' GROUP BY goods_id';
$goods_number = $GLOBALS['db']->getOne($sql);
if (empty($goods_number)) {
$goods_number = 0;
}
if (!empty($row['promote_end_date'])) {
$goods[$idx]['end_date'] = $row['promote_end_date'];
}
$goods[$idx]['soldnum'] = get_soldnum($row['goods_id']);
$goods[$idx]['jiesheng'] = $row['market_price'] - $row['promote_price'];
$goods[$idx]['zhekou'] = sprintf("%1\$.1f", $row['promote_price'] / $row['shop_price'] * 10);
$goods[$idx]['id'] = $row['goods_id'];
$goods[$idx]['number'] = $goods_number;
$goods[$idx]['name'] = $row['goods_name'];
$goods[$idx]['brief'] = $row['goods_brief'];
$goods[$idx]['brand_name'] = $row['brand_name'];
$goods[$idx]['goods_style_name'] = add_style($row['goods_name'], $row['goods_name_style']);
$goods[$idx]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
$goods[$idx]['short_style_name'] = add_style($goods[$idx]['short_name'], $row['goods_name_style']);
$goods[$idx]['market_price'] = $row['market_price'];
$goods[$idx]['shop_price'] = $row['shop_price'];
$goods[$idx]['thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);
$goods[$idx]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']);
$goods[$idx]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']);
$properties = get_goods_properties($row['goods_id']);
// 获得商品的规格和属性
$goods[$idx]['pro'] = $properties['pro']['商品属性'];
}
return $goods;
}
开发者ID:muqidi,项目名称:PHP,代码行数:53,代码来源:flash_sale.php
示例18: queryListByCatId
function queryListByCatId($cat_id, $page, $size, $keywords)
{
$sql = 'SELECT a.article_id, a.title, ac.cat_name, a.add_time, a.file_url, a.open_type, ac.cat_id, ac.cat_name, a.content ' . ' FROM ' . $GLOBALS['ecs']->table('article') . ' AS a, ' . $GLOBALS['ecs']->table('article_cat') . ' AS ac' . " WHERE a.is_open = 1 AND a.cat_id = ac.c
|
请发表评论