2017 © Pedro Peláez
 

library mews

mysql for courser

image

eclogue/mews

mysql for courser

  • Thursday, July 5, 2018
  • by superbogy
  • Repository
  • 1 Watchers
  • 0 Stars
  • 44 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 159 % Grown

The README.md

Mews

PHP ORM,used like mongodb shell., (*1)

install

composer require eclogue/mews, (*2)

Notice beta stage, (*3)

get start

<?php
use Mews\Model;
$config = [
  'host' => '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
$user->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., (*4)

Feature

  • connection pool
  • connection pool transaction
  • cache
  • ~~cluster connection pool~~

The Versions

05/07 2018

dev-master

9999999-dev

mysql for courser

  Sources   Download

MIT

The Requires

 

The Development Requires