承接 flyokai/zend-db-sql-insertmultiple 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

flyokai/zend-db-sql-insertmultiple

最新稳定版本:0.1.0

Composer 安装命令:

composer require flyokai/zend-db-sql-insertmultiple

包简介

README 文档

README

User docs → README.md · Agent quick-ref → CLAUDE.md · Agent deep dive → AGENTS.md

Multi-row INSERT INTO … VALUES (…), (…), (…) for Laminas DB.

Adds Laminas\Db\Sql\InsertMultiple, a single-statement multi-row insert builder that is otherwise missing from Laminas DB. Adapted from the original Zend\Db\Sql\Insert.

Features

  • Multi-row INSERT … VALUES (…), (…), (…)
  • INSERT … SELECT
  • Two value-merging strategies: VALUES_SET (replace) and VALUES_MERGE (append)
  • Compatible with Laminas Sql::buildSqlString() / Sql::prepareStatementForSqlObject()

Installation

composer require flyokai/zend-db-sql-insertmultiple

Quick start

Multi-row insert

use Laminas\Db\Sql\InsertMultiple;
use Laminas\Db\Sql\Sql;

$insert = new InsertMultiple('users');
$insert->columns(['email', 'name', 'status']);
$insert->values([
    ['alice@example.com', 'Alice', 1],
    ['bob@example.com',   'Bob',   0],
]);

$sql = new Sql($adapter);
$stmt = $sql->prepareStatementForSqlObject($insert);
$stmt->execute();

// → INSERT INTO users (email, name, status) VALUES (?, ?, ?), (?, ?, ?)

INSERT … SELECT

$insert = new InsertMultiple('users');
$insert->columns(['email', 'name']);
$insert->select(
    $sql->select('staging_users')->columns(['email', 'name'])
);

// → INSERT INTO users (email, name) SELECT email, name FROM staging_users

Value merging

$insert->values([['a@b.com', 'A']]);                                   // sets the rows
$insert->values(['c@d.com', 'C'], InsertMultiple::VALUES_MERGE);       // appends a row

API

Method Purpose
into(string $table) Set target table
columns(array $columns) Define column list (call before values())
values(array|Select $values, int $flag = VALUES_SET) Set/append rows or provide a Select
select(Select $select) Convenience for INSERT…SELECT
getRawState($key) Introspect internal state (for debugging)

Internals

  • Each row is ksort()-ed for consistent column ordering.
  • Named parameters are generated as insMulti0, insMulti1, …
  • Non-scalar values (Expressions, Literals) are cached per column to avoid redundant SQL generation.

Gotchas

  • columns() is required before values() with array data. Missing columns throws InvalidArgumentException.
  • No built-in chunking — generates a single statement for all rows. MySQL has statement size limits (~1000 tuples by default). Calling code must chunk.
  • Empty values produce empty SQL — if no rows, processInsert() returns an empty string silently.
  • Cannot mix VALUES_MERGE with a Select — throws.
  • Parameter naming is global — counter is shared across all rows (insMulti0, insMulti1, …).

See also

License

BSD-3-Clause

统计信息

  • 总下载量: 4
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 4
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2026-04-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固