public function replaceData($id, $data, $column = 'id') { $id = intval($id); $column = addslashes($column); if ($id == 0) { return false; } $fdata = $this->formatUpdateField($this->getTableName(), $data); if ($fdata === false) { self::$errMsg = $this->validatemsg; return false; } if ($this->checkIsExists($fdata)) { return false; } $check = $this->sql("SELECT COUNT(*) AS count FROM {$this->getTableName()} WHERE {$column}={$id}")->count(); if ($check == 0) { $fdata[$column] = $id; return $this->insertData($fdata); } else { return $this->sql("UPDATE " . $this->getTableName() . " SET " . array2sql($fdata) . " WHERE {$column}={$id}")->update(); } }
/** * CommonAct::act_getCategoryInfo($pid) * 获取产品本地某类别下的所有产品 * @param string $pid 类别id * @return string * @author wxb * @date 2013/11/13 */ public static function getCategoryInfo($pid) { self::initDB(); $sql = "SELECT id,name FROM " . C('DB_PREFIX') . "goods_category_pc WHERE is_delete=0 and pid={$pid} "; $query = self::$dbConn->query($sql); if ($query) { $ret = self::$dbConn->fetch_array_all($query); if (empty($ret[0])) { self::$errMsg = "无该类别列表"; return false; } return $ret; } self::$errMsg = "获取类别列表失败"; return false; }
public static function checkContent($content) { self::initDB(); $content = trim($content); $sql = "select id from " . self::$table . " where content = '{$content}' limit 1"; //echo $sql; $query = self::$dbConn->query($sql); if ($query) { $ret = self::$dbConn->fetch_array_all($query); return (int) $ret[0]['id']; //count($ret); //成功, 返回列表数据 } else { self::$errCode = "003"; self::$errMsg = "error"; return false; } }
public static function addIoRecores($paraArr) { self::initDB(); $ordersn = isset($paraArr['ordersn']) ? $paraArr['ordersn'] : ''; //发货单号或者是单据的ordersn $sku = $paraArr['sku']; //sku $amount = $paraArr['amount']; //数量 $positionId = isset($paraArr['positionId']) ? $paraArr['positionId'] : 0; //仓位ID $purchaseId = $paraArr['purchaseId']; //采购员id $ioType = $paraArr['ioType']; //出/入库,1为出库,2为入库 $ioTypeId = $paraArr['ioTypeId']; //出入库类型id,即出入库类型表中对应的id $userId = $paraArr['userId']; //添加人id $reason = isset($paraArr['reason']) ? $paraArr['reason'] : ''; //原因 $storeId = isset($paraArr['storeId']) ? intval($paraArr['storeId']) : 1; //仓库,默认为1 $createdTime = time(); $tName = 'wh_iorecords'; $set = "SET ordersn='{$ordersn}',sku='{$sku}',amount='{$amount}',positionId='{$positionId}',purchaseId='{$purchaseId}',ioType='{$ioType}',ioTypeId='{$ioTypeId}',userId='{$userId}',reason='{$reason}',createdTime='{$createdTime}',storeId='{$storeId}'"; $sql = "INSERT INTO {$tName} {$set}"; $query = self::$dbConn->query($sql); if ($query) { $insertId = self::$dbConn->insert_id($query); return $insertId; //成功, 返回插入的id } else { self::$errCode = "002"; self::$errMsg = "添加失败"; return false; //失败则设置错误码和错误信息, 返回false } }