Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hygsani/simple-query
https://github.com/hygsani/simple-query
Last synced: 20 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/hygsani/simple-query
- Owner: hygsani
- Created: 2017-07-17T16:09:39.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-07-17T16:38:44.000Z (over 7 years ago)
- Last Synced: 2023-10-21T13:32:50.789Z (about 1 year ago)
- Language: PHP
- Size: 1.95 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
SimpleQuery
===========example of use:
**connect to db**
```
$sq = new SimpleQUery('localhost', 'db', 'root', 'password');
```
**select all**
```
$rs = $sq->getAll('m_user');
```
>SELECT * FROM m_user**get one record by id**
```
$rs = $sq->getOneById('m_user', array('user_id' => 1));
```
>SELECT * FROM m_user WHERE user_id = 1```
$rs = $sq->getOneById('m_user', 4);
```
>SELECT * FROM m_user WHERE id = 4**get first record**
```
$rs = $sq->getFirst('m_user', 'user_id');
```
>SELECT * FROM m_user ORDER BY user_id ASC LIMIT 1**get last record**
```
$rs = $sq->getLast('m_user', 'user_id');
```
>SELECT * FROM m_user ORDER BY user_id DESC LIMIT 1**get all records by parameters**
```
$rs = $sq->getAllByParams('m_user',
array(
'name' => array('jo', 'like', 'and'),
'is_active' => array(0, '=')
)
);
```
>SELECT * FROM m_user WHERE name LIKE '%jo%' AND is_active = 0