承接 phpset/pdomodel 相关项目开发

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

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

phpset/pdomodel

最新稳定版本:v1.5

Composer 安装命令:

composer require phpset/pdomodel

包简介

Simple PDO-based Model

README 文档

README

Example of using:

class YoutubeVideosModel extends \PdoModel\PdoModel { const TABLE = 'youtube_videos'; protected function create($title, $src) { $this->insert(['title' => $title, 'src' => $src]); } } $youtubeVideosModel = new YoutubeVideosModel(new \Pdo()); $result = $youtubeVideosModel->select(['id', 'likes', 'url']) ->whereEqual('published', 1) ->where('likes', '>', 100) ->orderBy('likes desc') ->limit(100) ->offset(2000) ->groupBy('author') ->getAllRows(); var_dump($result);

Setup

composer require phpset/pdomodel

Check that you have proper PHP extentions

# Change 8.2 below to your current PHP version sudo apt install php8.2-pdo php8.2-pdo-mysql php8.2-pdo-sqlite

You need to create a usual PDO connection:

$connection = new \PDO( "mysql:host=127.0.0.1;dbname=YOURDBNAME;charset=utf8mb4", "YOURUSER", "YOURPASSWORD", [ \PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC, \PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION, ] );

Example for creating PDO in Symfony service config:

PDO: class: \PDO arguments: - "mysql:host=127.0.0.1;dbname=YOURDBNAME;charset=utf8mb4" - "YOURUSER" - "YOURPASSWORD" - !php/const PDO::ATTR_DEFAULT_FETCH_MODE: !php/const PDO::FETCH_ASSOC !php/const PDO::ATTR_ERRMODE: !php/const PDO::ERRMODE_EXCEPTION

SQLite example

$connection = new \PDO('sqlite::db.sqlite'); new PdoModel($connection)->setTable('test_table');

Tests

# run tests ./vendor/bin/phpunit # Check coverage php -dxdebug.mode=coverage ./vendor/bin/phpunit --coverage-text

Inspired by

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固