承接 ozh/sqltableextractor 相关项目开发

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

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

ozh/sqltableextractor

最新稳定版本:v1.0.1

Composer 安装命令:

composer require ozh/sqltableextractor

包简介

Extract table names from SQL queries (SELECT, INSERT, UPDATE, JOIN, subqueries)

README 文档

README

A lightweight PHP library to extract table names from SQL queries.

Features

  • ✅ Supports SELECT, INSERT, UPDATE queries
  • ✅ Handles all JOIN types (INNER, LEFT, RIGHT, FULL, CROSS)
  • ✅ Extracts tables from subqueries
  • ✅ Removes SQL comments and string literals
  • ✅ Cleans table names (backticks, quotes, database prefixes)
  • ✅ Manages table aliases
  • ✅ Zero dependencies

Installation

composer require --prefer-dist ozh/sqltableextractor

Usage

use Ozh\SQLTableExtractor\SqlTableExtractor;
$extractor = new SqlTableExtractor();

$query = "SELECT u.*, o.* FROM users u LEFT JOIN orders o ON u.id = o.user_id";
$tables = $extractor->extractTables($query);

## Examples
print_r($tables);
// Output: ['users', 'orders']
$extractor = new SqlTableExtractor();
$tables = $extractor->extractTables(

// Simple SELECT
$tables = $extractor->extractTables("SELECT * FROM users WHERE id = 1");
// ['users']

// Multiple JOINs
$tables = $extractor->extractTables(
    "SELECT * FROM table1 t1 
     INNER JOIN table2 t2 ON t1.id = t2.id 
     LEFT JOIN table3 t3 ON t2.id = t3.id"
);
// ['table1', 'table2', 'table3']

// INSERT
    "INSERT INTO customers (name, email) VALUES ('John', 'john@example.com')"
);
// ['customers']

// UPDATE with subquery
$tables = $extractor->extractTables(
    "UPDATE products SET price = 100 
     WHERE category_id IN (SELECT id FROM categories WHERE name = 'Electronics')"
);
// ['products', 'categories']

// Database prefix
$tables = $extractor->extractTables("SELECT * FROM `mydb`.`users`");
// ['users']

Requirements

  • PHP 7.4 or higher

License

Do whatever the hell you want with it. Or,
MIT License - See LICENSE file for details

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-21

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固