voku/paris

此包已被废弃且不再维护。作者建议使用j4mie/paris包。

PHP5的轻量级Active Record实现,基于Idiorm构建

维护者

详细信息

github.com/voku/paris

主页

源代码

问题

安装: 7,097

依赖者: 0

建议者: 0

安全: 0

星级: 7

关注者: 4

分支: 138

v1.7.6 2017-08-10 19:52 UTC

README

Build Status codecov.io Codacy Badge SensioLabsInsight Latest Stable Version Total Downloads Latest Unstable Version PHP 7 ready License

Paris

http://j4mie.github.com/idiormandparis/

警告:此仅为从以下地址的维护分支:"https://github.com/j4mie/paris/"

信息:您可以使用我的Simple Active Record库代替Paris: "https://github.com/voku/simple-active-record"

安装

推荐的安装方式是通过Composer

$ composer require voku/paris

PHP5的轻量级Active Record实现。

基于Idiorm构建。

在PHP 5.3+上进行了测试 - 可能可以在较旧版本上通过PDO和正确的数据库驱动程序工作。

BSD许可下发布。

特性

  • 极其简单的配置。
  • 暴露了Idiorm的全功能流畅查询API。
  • 支持关联。
  • 简单的机制来封装常用的查询在过滤器方法中。
  • 基于PDO
  • 使用预处理语句来防止SQL注入攻击。
  • 数据库无关。目前支持SQLite、MySQL、Firebird和PostgreSQL。可能支持其他数据库,请尝试!
  • 支持使用方法链对模型集合进行过滤或同时对多个结果应用操作。
  • 支持多个连接

文档

文档托管在Read the Docs上:paris.rtfd.org

构建文档

您需要安装Sphinx,然后在文档文件夹中运行

make html

现在文档将在docs/_build/html/index.html

看看一些代码

/**
 * User: a sample user-class
 *
 * @property-read int    $id
 * @property-read string $first_name
 */
class User extends Model {
  public function tweets() {
      return $this->has_many('Tweet');
  }
  
  public function getId()
  {
    return $this->id;
  }
    
  public function getFirstName()
  {
    return $this->first_name
  }
}

/**
 * Tweet: a sample twitter-class
 *
 * @property-read int    $id
 * @property-read string $text
 */
class Tweet extends Model {
  
}

$user = Model::factory('User')
  ->where_equal('username', 'j4mie')
    ->find_one();
$user->first_name = 'Jamie';
$user->save();

$tweets = $user->tweets()->find_many();
foreach ($tweets as $tweet) {
  echo $tweet->text;
}