https://github.com/eclogue/mews
https://github.com/eclogue/mews
connection-pool orm php7
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/eclogue/mews
- Owner: eclogue
- License: mit
- Created: 2017-03-10T06:49:52.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2020-03-06T16:37:55.000Z (about 6 years ago)
- Last Synced: 2024-04-24T23:40:41.528Z (about 2 years ago)
- Topics: connection-pool, orm, php7
- Language: PHP
- Size: 78.1 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Mews
PHP ORM,used like mongodb shell.
### install
`composer require eclogue/mews`
**Notice** beta stage
### get start
```php
'127.0.0.1',
'user' => 'root',
'password' => '123123',
'dbname' => 'test',
];
class User extends Model {
public $table = 'users';
public $fields = [
'id' => ['pk' => true, 'auto' => true, 'type' => 'int', 'column' => 'id' ],
'username' => ['type' => 'string', 'column' => 'username']
// ...
];
}
$user = new User($config);
$condition = [
'id' => ['$gt' => 1, '$lt' => 100, '$neq' => 23],
'$or' => [
'email' => 'aaxx@scac.com',
'status' => '1',
],
'age' => ['$lt' => 70]
];
$userInfo = $user->findById(1);
$user->findOne($condition);
$user->findByIds([1, 2, 3]);
$data = [
'nickname' => 'damn it',
'status' => [ '$inc' => -1]
];
$where = [
'status' => [
'$gt' => 0
]
];
$userInfo->update($where, $data);
// sql: UPDATE `users` SET `nickname`=?,`status`=`status` + -1 WHERE (`id` = ? AND `status` > ? ) #args: ["damn it",1,0]
```
-------
### builder
```php
builder()
->field('*')
->where($condition)
->order(['id' => 'desc'])
->skip(100)
->limit(10)
->select();
// execute sql: SELECT * FROM `user` WHERE (`id`>'1' and `id`<'100' and `id`!='23') or (`email`='aaxx@scac.com' and `status`='1') and (`age`<'70') ORDER BY `id` DESC limit 10 offset 100;
```
### cache
mews cache is dependence primary key `id`.If you want to use cache please make sure your table had primary key `id`.
### Feature
- connection pool
- connection pool transaction
- cache
- ~~cluster connection pool~~