utipd/mysqlmodel
Composer 安装命令:
composer require utipd/mysqlmodel
包简介
A minimalistic manager for storing and retrieving MySQL rows as PHP models. Does not handle schemas. Does allow treating mysql rows like documents.
README 文档
README
A MysqlModel component for UTipdMe.
A simple ORM to map MySQL table rows to PHP models and back.
Usage Example:
<?php // create a class // this maps to table user in MySQL (you must create this yourself) class UserDirectory extends \Utipd\MysqlModel\BaseDocumentMysqlDirectory { protected $column_names = ['email']; } // pass in your PDO object $user_directory = new UserDirectory(new \PDO('mysql:dbname=testdb;host=127.0.0.1')); // find by email $user = $user_directory->findOne(['email' => 'johny@appleseed.com']); // access rows and properties print $user['email']."\n"; // update in MySQL, adding arbitrary columns $user_directory->update($user, ['firstName' => 'John', 'lastName' => 'Appleseed']); // get the user again from the database $user = $user_directory->reload($user); print $user['firstName']." ".$user['lastName']."\n";
统计信息
- 总下载量: 101
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-07-31