itrn0/php-medoo-wrapper 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

itrn0/php-medoo-wrapper

最新稳定版本:v1.1.2

Composer 安装命令:

composer require itrn0/php-medoo-wrapper

包简介

A wrapper for the Medoo library that allows for easy fetching of rows.

README 文档

README

This library extends Medoo's functionality with added methods for safer database interaction, including a SqlInterpolator class for safe variable interpolation and extended fetch methods.

Installation

You can install the library using composer:

composer require itrn0/php-medoo-wrapper

Usage

require __DIR__ . '/vendor/autoload.php';

use Itrn0\MedooWrapper\MedooWrapper;
use Itrn0\SqlInterpolator\SqlInterpolator;

$db = new MedooWrapper([
    'database_type' => 'mysql',
    'database_name' => 'test',
    'server' => 'localhost',
    'username' => 'root',
    'password' => ''
]);

$usernames = ['alice', 'bob'];
$res = $db->query(function (SqlInterpolator $interp) use ($usernames) {
    return <<<SQL
        SELECT * FROM users WHERE id IN ({$interp(...$usernames)})
    SQL;
});
$users = $res->fetchAll();

Fetching Data

You can fetch data using fetch and fetchAll methods.

// Fetch a single row from the query result set
$data = $db->fetch("SELECT * FROM `users` WHERE `name` = :name", [
    ':name' => 'John',
]);

// Returns an array containing all of the result set rows
$data = $db->fetchAll("SELECT * FROM `users`");

License

This library is licensed under the MIT License.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-01-24