Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/michabbb/mysqlihelper
A simple mysqli helper with lazy-connection, auto-reconnect and named-parameters
https://github.com/michabbb/mysqlihelper
helper lazy-connection mysqli named-parameters php wrapper
Last synced: 21 days ago
JSON representation
A simple mysqli helper with lazy-connection, auto-reconnect and named-parameters
- Host: GitHub
- URL: https://github.com/michabbb/mysqlihelper
- Owner: michabbb
- License: gpl-3.0
- Created: 2018-10-05T16:23:43.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-01-27T18:50:38.000Z (almost 3 years ago)
- Last Synced: 2024-12-09T04:51:38.940Z (about 2 months ago)
- Topics: helper, lazy-connection, mysqli, named-parameters, php, wrapper
- Language: PHP
- Homepage:
- Size: 42 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
This is a super simple basic wrapper for mysqli, with some extras:
- lazy connection
- auto-reconnect
- named-parameters**Example usage:**
```php
'xxxxxxx',
'port' => 3306,
'user' => 'xxxxxx',
'pwd' => 'xxxxxx',
'db' => 'xxxxx',
'charset' => 'utf8',
'trace' => true
]
);
$newQuery = $MySQLiHelper->query('select * from table limit 0,10');
foreach ($newQuery->result as $data) {
echo $data['table_field']."\n";
}
```
the defaults are:* charset: utf8
* port: 3306
* trace: true**The best:** this class supports regular **AND** named _parameters_ - thanks to PEAR:MDB2 where i got the code from :-)
so both works:
```php
$MySQLiHelper->query('select * from table where a=? and b=?',[1,1]);
```
**IS THE SAME LIKE**
```php
$MySQLiHelper->query('select * from table where a=:my_placeholder and b=:my_placeholder',['my_placeholder' => 1]);
```
You can call `$MySQLiHelper->connect()` manually, but the class uses lazy connection, so as soon as the first query is done,
a connection to the mysql server will be established.In case the connection gets lost or a first connection does not work (whyever), there is a default auto-reconnect of 5 tries
with a sleep of 3 seconds. you can change this with:`$MySQLiHelper->setAutoReconnectMaxTry(x)`
`$MySQLiHelper->setAutoReconnectSleep(x)`
`$MySQLiHelper->setAutoReconnect(false)`
`$MySQLiHelper->setLowerTableFields(false)`**You need a php developer?**
Contact me via[XING](https://www.xing.com/profile/Michael_Bladowski/cv)
[LINKEDIN](https://www.linkedin.com/in/macropage/)
[TWITTER](https://twitter.com/michabbb)
[G+](https://plus.google.com/+MichaelBladowski)....