yehorbk/pldb

一个提供与简单自包含数据库工作功能的库。

v1.0.0 2020-09-02 10:37 UTC

This package is not auto-updated.

Last update: 2024-09-27 01:13:02 UTC


README

一个提供与简单自包含数据库工作功能的库。

概念

项目的核心思想是允许任何级别的程序员能够无需安装和配置即可使用数据库进行简单的操作。

安装

使用 Composer 将 PLDB 安装到您的项目中

$ composer require yehorbk/pldb

入门指南

以下是一个简单的程序,展示了如何创建数据库、创建表、插入和选择数据。

<?php

  require_once "vendor/autoload.php";
  use PLDB\PLDBService;

  // Initializing PLDBService
  $pldb = new PLDBService();

  // Creating Database
  $database = $pldb->createDatabase('pldb-gs');

  // Creating Table
  $usersScheme = array( // Table scheme (field name => field type)
    "name" => "text",
    "age" => "number",
    "address" => "text",
  );
  $table = $database->createTable('users', $usersScheme);

  // Creating Users and Inserting Data to Table
  class User {
    public $name;
    public $age;
    public $address;
  }

  $john = new User();
  $john->name = "John";
  $john->age = 27;
  $john->address = "London, UK";

  $abigail = array(
    "name" => "Abigail",
    "age" => 25,
    "address" => "New York City, US",
  );

  // There is the ability to insert both an object and an array
  $table->insert($john);
  $table->insert($abigail);

  // Selecting and Printing Data
  $condition = array(
    "name" => "Abigail",
  );
  $usersArray = $table->select($condition);
  print_r($usersArray);

?>

文档

有关库 API 的更多信息,请查看 文档

作者

Yehor Bublyk: GitHubTwitter