2023/10/27–C#–staggered array, forEach, two-dimensional array, Array array; array API, variable parameter params···

1. Interleaved array One-dimensional array whose data type is one-dimensional array int[][] intsArray = new int[2][] { new int[5] { 1, 2, 3, 4, 5 }, new int[4] { 1, 2, 3, 4 } } ; string[] stringArray1 = { “1”, “2” }; string[] stringArray2 = { “3”, “2” }; string[][] stringsArray = new string[2][] […]

Database foreach union all query lambda expression, lambda expression

Code String accountId = LoginUtils.getLoginAccountId(); log.info(“BaseUserCollectInfoServiceImpl.getMerchantInfoList; Start querying the list of favorite merchants accountId: {}”, accountId); PageInfo<BaseMerchantInfoResp> pageInfo = PageHelper.startPage(req.getPageNum(), req.getPageSize()) .doSelectPageInfo(() -> userCollectInfoMapper.getMerchantInfoList(accountId)); if (pageInfo.getTotal() == 0) { return PageInfoUtils.emptyPageInfo(req); } List<BaseMerchantInfoResp> respList = pageInfo.getList(); List<String> accountIds = respList.stream().map(BaseMerchantInfoResp::getAccountId).collect(Collectors.toList()); if (CollectionUtils.isEmpty(accountIds)) { return pageInfo; } //todo queries the merchant service list. Those that are […]

MyBatis dynamic statements where/if, set, trim, choose/when/otherwise, foreach tag, and sql fragments

1. Environment preparation 1. Prepare the database and insert data CREATE TABLE `t_emp` ( emp_id INT AUTO_INCREMENT, emp_name CHAR(100), emp_salary DOUBLE(10, 5), PRIMARY KEY (emp_id) ); INSERT INTO `t_emp`(emp_name,emp_salary) VALUES(“tom”,200.33); INSERT INTO `t_emp`(emp_name,emp_salary) VALUES(“jerry”,666.66); INSERT INTO `t_emp`(emp_name,emp_salary) VALUES(“andy”,777.77); 2. Write entity classes package com.suchuanlin.pojo; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @Data @NoArgsConstructor @AllArgsConstructor public class […]

MyBatis (where, set, foreach) tag

where tag A condition “1=1” was added to the SQL statement in the previous section. If this condition is not added, it may become an incorrect statement like the following. SELECT id,name,url,age,country FROM website AND name LIKE CONCAT(‘%’,#{name},’%’) Obviously the above statement will cause SQL syntax exceptions, but adding a condition like “1=1” is very […]

foreach problem in php

The foreach structure was introduced in php4, which is a simple way to traverse an array. Compared with the traditional for loop, foreach can obtain key-value pairs more conveniently. Before php5, foreach could only be used for arrays; after php5, foreach could also be used to traverse objects (see: Traversing Objects for details). This article […]

Mybatis automatic implementation of batch deletion through forEach—–Mybatis framework

<?xml version=”1.0″ encoding=”UTF-8″?> <!DOCTYPE mapper PUBLIC “-//mybatis.org//DTD Mapper 3.0//EN” “http://mybatis.org/dtd/mybatis-3-mapper.dtd”> <mapper namespace=”com.powernode.mybatis.mappers.CarMapper”> <!– The attribute of the if tag is required. The test tag in the if tag must be true. The sql statement in the if tag will be automatically spliced, but not vice versa –> <!– The value of the test tag should […]

Mybatis automatic implementation and details of adding data in batches through forEach—–Mybatis framework

<?xml version=”1.0″ encoding=”UTF-8″?> <!DOCTYPE mapper PUBLIC “-//mybatis.org//DTD Mapper 3.0//EN” “http://mybatis.org/dtd/mybatis-3-mapper.dtd”> <mapper namespace=”com.powernode.mybatis.mappers.CarMapper”> <!– The attribute of the if tag is required. The test tag in the if tag must be true. The sql statement in the if tag will be automatically spliced, but not vice versa –> <!– The value of the test tag should […]

Two implementation methods of Mybatis deleting data in batches through forEach —–Mybatis framework

<?xml version=”1.0″ encoding=”UTF-8″?> <!DOCTYPE mapper PUBLIC “-//mybatis.org//DTD Mapper 3.0//EN” “http://mybatis.org/dtd/mybatis-3-mapper.dtd”> <mapper namespace=”com.powernode.mybatis.mappers.CarMapper”> <!– The attribute of the if tag is required. The test tag in the if tag must be true. The sql statement in the if tag will be automatically spliced, but not vice versa –> <!– The value of the test tag should […]