承接 pleonovich/fultone 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

pleonovich/fultone

Composer 安装命令:

composer require pleonovich/fultone

包简介

Fultone is simple object-relational queries helper for SafeMySQL

README 文档

README

simple object-relational queries helper for SafeMySQL

Requirements:

https://github.com/colshrapnel/safemysql

DB connection configuration

Fultone\Config::$db_user = 'root';
Fultone\Config::$db_pass = '1234';
Fultone\Config::$db_name = 'simdb';
Fultone\Config::$db_charset = 'utf8';

Using Models

Create model for users table

use Fultone\DBmodel as DBmodel;
use Fultone\DBtable as DBtable;
use Fultone\DBfield as DBfield;

class Users extends DBmodel {

    public $name = 'user_list';

    protected function schema(DBtable $table) {
        $table
        ->field('id', DBfield::TYPE_INT, 10, false)
        ->field('user_name', DBfield::TYPE_VARCHAR, 255, false)
        ->field('user_login', DBfield::TYPE_VARCHAR, 255, false)
        ->field('email', DBfield::TYPE_VARCHAR, 255, false)
        ->field('secret', DBfield::TYPE_TEXT, null, false);
    }

    // Set some data for admin
    protected function setData(){
        return [
            'user_name'=>'Admin',
            'user_login'=>'admin',
            'email'=>'admin@admin.net',
            'secret'=>'12345'
        ];
    }
}

$users = new Users();

// Migrate table to connected db
$users->migrate();

// Migrate data form model class
$users->insertData();

Insert into table

$users->create([
    "name" => "john smith",
    "phone" => "+375441212121",
    "description" => "some text about john smith"
]);

Select from table

// get all rows
$result = $users->findAll();

// get one row by value
$result = $users->findOne([ "id"=> 1 ]);

// set operator
// one of '=','!=','<>','>','<','>=','<=','LIKE','IS','IN','NOT IN'
$result = $users->findAll([ "id"=> ["!=" => 1 ]);

// operator IN
$result = $users->findAll("id"=>[ "IN" => [1,2] ]);

// search by string
$result = $users->findAll([ "name"=> ["LIKE"=>"%john%"] ]);

// conditions operators AND, OR, NOT
$result = $users->findAll([ "AND"=> [
    "id" => ["!=" => 1 ],
    "phone" => ["LIKE"=>"+37529%"],
]);

Update table

$users->where([
    "id"=> 1
])->update([
    "name" => "john smith",
    "phone" => "+375441212121",
    "description" => "some text about john smith"
]);

Delete from table

$users->delete([ "id"=> 1 ]);

统计信息

  • 总下载量: 20
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2019-07-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固