Skip to content

Commit 347515f

Browse files
committed
[update] update doc for v2.2.0
1 parent 2f91c10 commit 347515f

3 files changed

Lines changed: 61 additions & 48 deletions

File tree

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2024 Angel Lai
3+
Copyright (c) 2025 Angel Lai
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,22 @@
1515
1616
## Features
1717

18-
* **Lightweight** - Portable with only one file.
18+
* **Lightweight** - Single-file framework with minimal dependencies.
1919

20-
* **Easy** - Easy to learn and use, with a friendly construction.
20+
* **Easy** - Simple and intuitive API for quick integration.
2121

22-
* **Powerful** - Supports various common and complex SQL queries, data mapping and prevents SQL injection.
22+
* **Powerful** - Supports complex SQL queries, data mapping, and SQL injection prevention.
2323

24-
* **Compatible** - Supports MySQL, MSSQL, SQLite, MariaDB, PostgreSQL, Sybase, Oracle, and more.
24+
* **Compatible** - Works with MySQL, MariaDB, PostgreSQL, SQLite, MSSQL, Oracle, Sybase, and more.
2525

26-
* **Friendly** - Works well with every PHP framework, such as Laravel, Codeigniter, Yii, Slim, and frameworks that support singleton extension or composer.
26+
* **Friendly** - Integrates seamlessly with Laravel, CodeIgniter, Yii, Slim, and other PHP frameworks.
2727

28-
* **Free** - Under the MIT license, you can use it anywhere, for whatever purpose.
28+
* **Free** - Licensed under MIT, free to use for any purpose.
2929

3030
## Requirements
3131

32-
- PHP 7.3+
33-
- Installed PDO extension
32+
- PHP 7.3 or later
33+
- PDO extension enabled
3434

3535
## Get Started
3636

@@ -41,19 +41,19 @@ Add Medoo to the `composer.json` configuration file.
4141
$ composer require catfan/medoo
4242
```
4343

44-
And update the composer
44+
Then update Composer
4545
```bash
4646
$ composer update
4747
```
4848

4949
```php
50-
// Require Composer's autoloader.
50+
// Require Composer's autoloader
5151
require 'vendor/autoload.php';
5252

53-
// Use the Medoo namespace.
53+
// Import Medoo namespace
5454
use Medoo\Medoo;
5555

56-
// Connect to the database.
56+
// Initialize database connection
5757
$database = new Medoo([
5858
'type' => 'mysql',
5959
'host' => 'localhost',
@@ -62,11 +62,13 @@ $database = new Medoo([
6262
'password' => 'your_password'
6363
]);
6464

65+
// Insert data
6566
$database->insert('account', [
6667
'user_name' => 'foo',
6768
'email' => 'foo@bar.com'
6869
]);
6970

71+
// Retrieve data
7072
$data = $database->select('account', [
7173
'user_name',
7274
'email'
@@ -83,18 +85,24 @@ echo json_encode($data);
8385
```
8486

8587
## Contribution Guidelines
88+
Before submitting a pull request, ensure compatibility with multiple database engines and include unit tests when possible.
8689

87-
Before starting a new pull request, please ensure compatibility with other databases and write unit tests whenever possible.
90+
### Testing & Code Style
91+
- Run `phpunit tests` to execute unit tests.
92+
- Use `php-cs-fixer fix` to enforce code style consistency.
8893

89-
Run `phpunit tests` for unit testing and `php-cs-fixer fix` to fix code style.
94+
### Commit Message Format
95+
Each commit should begin with a tag indicating the type of change:
9096

91-
Each commit should start with a tag indicating the type of change: `[fix]`, `[feature]`, or `[update]`.
97+
- `[fix]` for bug fixes
98+
- `[feature]` for new features
99+
- `[update]` for improvements
92100

93-
Please keep it simple and keep it clear.
101+
Keep contributions simple and well-documented.
94102

95103
## License
96104

97-
Medoo is released under the MIT license.
105+
Medoo is released under the MIT License.
98106

99107
## Links
100108

src/Medoo.php

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
*
77
* The Lightweight PHP Database Framework to Accelerate Development.
88
*
9-
* @version 2.1.12
10-
* @author Angel Lai
9+
* @version 2.2.0
1110
* @package Medoo
12-
* @copyright Copyright 2024 Medoo Project, Angel Lai.
11+
* @author Angel Lai
12+
* @copyright Angel Lai
1313
* @license https://opensource.org/licenses/MIT
1414
* @link https://medoo.in
1515
*/
@@ -71,28 +71,28 @@ class Raw
7171
class Medoo
7272
{
7373
/**
74-
* The PDO object.
74+
* The PDO database connection instance.
7575
*
7676
* @var \PDO
7777
*/
7878
public $pdo;
7979

8080
/**
81-
* The type of database.
81+
* The database type.
8282
*
8383
* @var string
8484
*/
8585
public $type;
8686

8787
/**
88-
* Table prefix.
88+
* The table prefix.
8989
*
9090
* @var string
9191
*/
9292
protected $prefix;
9393

9494
/**
95-
* The PDO statement object.
95+
* Current PDO statement instance.
9696
*
9797
* @var \PDOStatement
9898
*/
@@ -106,91 +106,91 @@ class Medoo
106106
protected $dsn;
107107

108108
/**
109-
* The array of logs.
109+
* Logged queries.
110110
*
111111
* @var array
112112
*/
113113
protected $logs = [];
114114

115115
/**
116-
* Determine should log the query or not.
116+
* Whether query logging is enabled.
117117
*
118118
* @var bool
119119
*/
120120
protected $logging = false;
121121

122122
/**
123-
* Determine is in test mode.
123+
* Whether the database is in test mode.
124124
*
125125
* @var bool
126126
*/
127127
protected $testMode = false;
128128

129129
/**
130-
* The last query string was generated in test mode.
130+
* The last generated query string in test mode.
131131
*
132132
* @var string
133133
*/
134134
public $queryString;
135135

136136
/**
137-
* Determine is in debug mode.
137+
* Whether debug mode is enabled.
138138
*
139139
* @var bool
140140
*/
141141
protected $debugMode = false;
142142

143143
/**
144-
* Determine should save debug logging.
144+
* Whether debug logging is enabled.
145145
*
146146
* @var bool
147147
*/
148148
protected $debugLogging = false;
149149

150150
/**
151-
* The array of logs for debugging.
151+
* Logged debug queries.
152152
*
153153
* @var array
154154
*/
155155
protected $debugLogs = [];
156156

157157
/**
158-
* The unique global id.
158+
* The unique global identifier.
159159
*
160-
* @var integer
160+
* @var int
161161
*/
162162
protected $guid = 0;
163163

164164
/**
165-
* The returned id for the insert.
165+
* The last inserted record ID.
166166
*
167167
* @var string
168168
*/
169169
public $returnId = '';
170170

171171
/**
172-
* Error Message.
172+
* The last error message.
173173
*
174174
* @var string|null
175175
*/
176176
public $error = null;
177177

178178
/**
179-
* The array of error information.
179+
* The last error details.
180180
*
181181
* @var array|null
182182
*/
183183
public $errorInfo = null;
184184

185185
/**
186-
* The keyword to connect the table alias.
186+
* The connector used for table aliases.
187187
*
188188
* @var string
189189
*/
190190
protected $tableAliasConnector = ' AS ';
191191

192192
/**
193-
* The quote pattern string.
193+
* The pattern used for quoting identifiers.
194194
*
195195
* @var string
196196
*/
@@ -218,11 +218,13 @@ class Medoo
218218
protected const ALIAS_PATTERN = "[\p{L}_][\p{L}\p{N}@$#\-_]*";
219219

220220
/**
221-
* Connect the database.
221+
* Establish a database connection.
222222
*
223+
* Example usage:
224+
*
223225
* ```
224226
* $database = new Medoo([
225-
* // required
227+
* // Required
226228
* 'type' => 'mysql',
227229
* 'database' => 'name',
228230
* 'host' => 'localhost',
@@ -238,7 +240,7 @@ class Medoo
238240
*
239241
* @param array $options Connection options
240242
* @return Medoo
241-
* @throws PDOException
243+
* @throws PDOException If the connection fails
242244
* @link https://medoo.in/api/new
243245
* @codeCoverageIgnore
244246
*/
@@ -519,6 +521,7 @@ public function __construct(array $options)
519521
/**
520522
* Setup the database type.
521523
*
524+
* @param string The database type string.
522525
* @return void
523526
*/
524527
public function setupType(string $type)
@@ -744,9 +747,9 @@ function ($matches) {
744747
}
745748

746749
/**
747-
* Quote a string for use in a query.
750+
* Escape and quote a string for use in an SQL query.
748751
*
749-
* @param string $string
752+
* @param string $string The string to be quoted.
750753
* @return string
751754
*/
752755
public function quote(string $string): string
@@ -759,10 +762,11 @@ public function quote(string $string): string
759762
}
760763

761764
/**
762-
* Quote table name for use in a query.
765+
* Quote a table name for use in an SQL query.
763766
*
764-
* @param string $table
767+
* @param string $table The table name to be quoted.
765768
* @return string
769+
* @throws InvalidArgumentException If the table name is invalid.
766770
*/
767771
public function tableQuote(string $table): string
768772
{
@@ -774,10 +778,11 @@ public function tableQuote(string $table): string
774778
}
775779

776780
/**
777-
* Quote column name for use in a query.
781+
* Quote a column name for use in an SQL query.
778782
*
779-
* @param string $column
783+
* @param string $column The column name to be quoted.
780784
* @return string
785+
* @throws InvalidArgumentException If the column name is invalid.
781786
*/
782787
public function columnQuote(string $column): string
783788
{

0 commit comments

Comments
 (0)