Skip to content

Commit 02b53be

Browse files
committed
發布 1.0.0 版本。
0 parents  commit 02b53be

File tree

5 files changed

+481
-0
lines changed

5 files changed

+481
-0
lines changed

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# 忽略 VSCode 的工作台設定檔案
2+
*.code-workspace
3+
4+
# 忽略 macOS 系統自動生成的 .DS_Store 檔案與資料夾圖標
5+
.DS_Store
6+
Icon?
7+
8+
# 忽略其他
9+
memo.md

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 邱敬幃 Pardn Chiu
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# PD\SQL
2+
3+
> A fluent SQL query builder for PHP that provides an elegant and safe way to build and execute database queries. Built on top of PDO, this library offers a chainable API that makes database interactions more intuitive and maintainable.
4+
5+
![tag](https://img.shields.io/badge/tag-PHP%20Library-bb4444)
6+
![size](https://img.shields.io/github/size/pardnchiu/PHPSQL/src/SQL.php)<br>
7+
![version](https://img.shields.io/packagist/v/pardnchiu/sql)
8+
![download](https://img.shields.io/packagist/dm/pardnchiu/sql)
9+
10+
## Features
11+
- Fluent interface for building SQL queries
12+
- Safe parameter binding to prevent SQL injection
13+
- Support for complex JOIN operations (INNER, LEFT, RIGHT)
14+
- Dynamic WHERE clause construction
15+
- Ordering and pagination support
16+
- Transaction handling
17+
- Query execution time monitoring
18+
- Environment-based configuration
19+
- Automatic connection management
20+
21+
## functions
22+
23+
- Table selection with `table()`
24+
- Custom field selection with `select()`
25+
- Conditional filtering with `where()`
26+
- Join operations with `join()`, `left_join()`, `right_join()`
27+
- Result ordering with `order_by()`
28+
- Pagination with `limit()` and `offset()`
29+
- Record creation with `insertGetId()`
30+
- Record updates with `update()`
31+
- Total row count with `total()`
32+
- Raw query execution with `query()` for complex custom queries
33+
34+
## How to Use
35+
36+
### Install
37+
38+
```SHELL
39+
composer require pardnchiu/sql
40+
```
41+
42+
### Use
43+
44+
```PHP
45+
<?php
46+
47+
use PD\SQL;
48+
49+
$result_user_0 = SQL::table('users')
50+
->where('status', 'active')
51+
->where('age', '>', 18)
52+
->get();
53+
54+
$result_order = SQL::table('orders')
55+
->select('orders.*', 'users.name')
56+
->join('users', 'orders.user_id', 'users.id')
57+
->where('orders.status', 'pending')
58+
->get();
59+
60+
$result_product = SQL::table('products')
61+
->total()
62+
->limit(10)
63+
->offset(0)
64+
->order_by('created_at', 'DESC')
65+
->get();
66+
67+
$result_user_1 = SQL::query(
68+
"SELECT * FROM users WHERE status = ? AND role = ?",
69+
['active', 'admin']
70+
);
71+
```
72+
73+
## License
74+
75+
This source code project is licensed under the [MIT](https://github.com/pardnchiu/PHPSQL/blob/main/LICENSE) license.
76+
77+
## Creator
78+
79+
<img src="https://avatars.githubusercontent.com/u/25631760" align="left" width="96" height="96" style="margin-right: 0.5rem;">
80+
81+
<h4 style="padding-top: 0">邱敬幃 Pardn Chiu</h4>
82+
83+
<a href="mailto:dev@pardn.io" target="_blank">
84+
<img src="https://pardn.io/image/email.svg" width="48" height="48">
85+
</a> <a href="https://linkedin.com/in/pardnchiu" target="_blank">
86+
<img src="https://pardn.io/image/linkedin.svg" width="48" height="48">
87+
</a>
88+
89+
***
90+
91+
©️ 2024 [邱敬幃 Pardn Chiu](https://pardn.io)

composer.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "pardnchiu/sql",
3+
"description": "A fluent SQL query builder for PHP that provides an elegant and safe way to build and execute database queries. Built on top of PDO, this library offers a chainable API that makes database interactions more intuitive and maintainable.",
4+
"type": "library",
5+
"license": "MIT",
6+
"authors": [
7+
{
8+
"name": "邱敬幃 Pardn Chiu",
9+
"email": "dev@pardn.io"
10+
}
11+
],
12+
"minimum-stability": "stable",
13+
"require": {
14+
"php": ">=8.0"
15+
},
16+
"require-dev": {
17+
},
18+
"autoload": {
19+
"psr-4": {
20+
"PD\\": "src/"
21+
},
22+
"exclude-from-classmap": [
23+
".gitignore",
24+
"*.md",
25+
"composer.json"
26+
]
27+
},
28+
"autoload-dev": {
29+
"psr-4": {
30+
}
31+
},
32+
"scripts": {
33+
},
34+
"extra": {
35+
"branch-alias": {
36+
}
37+
},
38+
"config": {
39+
"sort-packages": true
40+
}
41+
}

0 commit comments

Comments
 (0)