承接 vista-php/database 相关项目开发

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

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

vista-php/database

最新稳定版本:1.0.3

Composer 安装命令:

composer require vista-php/database

包简介

Database abstraction layer

README 文档

README

Introduction

Vista PHP Database module is a part of Vista PHP Framework, but can also be used as a stand alone ORM (Object Relational Mapper) for PHP. It is designed to simplify database manipulation and provide a secure way to interact with databases.

Getting Started

Installation

composer require vista-php/database

Configuration

The database configuration should be stored in the config/database.php file. The file should return an array with the following keys: DB_TYPE, DB_HOST, DB_NAME, DB_USER and DB_PASS

For SQLite:

return [
    'DB_TYPE' => 'sqlite',
    'DB_NAME' => __DIR__ . '../database/database.sqlite',
];

For MySQL:

return [
    'DB_TYPE' => 'mysql',
    'DB_NAME' => 'database',
    'DB_HOST' => 'localhost',
    'DB_USER' => 'root',
    'DB_PASS' => 'root'
];

Usage

All you need to do is extend the Vista\Model\Model class in one of your model class and define the table name, primary key, columns and relationship methods.

Example:

use Vista\Model\Model;

class User extends Model
{
    protected string $table = 'users';
    protected string $primaryKey = 'id';
    protected array $columns = ['id', 'name', 'username', 'password'];
    protected array $relationships = ['posts']

    public function posts()
    {
        return Post::where('user_id', $this->id);
    }
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-03-19

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固