notyes/php-active-record

独立Active Record库。从CodeIgniter 3.0RC2开始,包含Active Record和数据库库,但不包含CodeIgniter的其他部分

v0.1.1 2016-10-28 04:49 UTC

This package is auto-updated.

Last update: 2024-09-06 02:49:53 UTC


README

基于CodeIgnitor的数据库实现。它使用3.0版本的Active Record和数据库库,使其在不包含CodeIgniter其他部分的情况下工作。

设置

composer require notyes/php-active-record dev-master

用法

// Include
use ActiveRecord\ActiveDatabase;

...

// Create Database configs
$db_config = array(
    'hostname' => "localhost",
    'username' => "username",
    'password' => "password",
    'database' => "database_name",
    'dbdriver' => "mysql",
    'pconnect' => FALSE,
    'db_debug' => TRUE
);

// Add Config and give it a name
ActiveDatabase::addConfig("read", $db_config);

//Use the named connection
$query = ActiveDatabase::get("read")->get('table_name')
$row = $query->result_array();
print_r($row);

文档

有关如何使用Active Record的更多信息:请参阅CodeIgnitor的参考文档

数据库参考

$this->db

gets replaced by

ActiveDatabase::get("db_reference_name")

贡献

感谢Documentopia.com的基础设置