helios-ag / fm-lessql-bundle

Lessql bundle,为您的 Symfony 项目添加 LessQL ORM PHP

安装: 18

依赖者: 0

建议者: 0

安全: 0

星标: 2

关注者: 3

分叉: 0

开放问题: 0

类型:symfony-bundle

0.1 2015-05-31 11:31 UTC

This package is auto-updated.

Last update: 2024-08-29 00:40:28 UTC


README

LessQL 在 Symfony2 中的集成

LessQL 是 PHP 中轻量级且功能强大的对象关系映射替代方案。

安装

步骤 1:安装

使用 Composer,只需将以下配置添加到您的 composer.json

或者您可以使用 composer 安装此包:在您的 composer.json 中添加 FMBbcodeBundle

    composer require helios-ag/fm-lessql-bundle

现在运行以下命令让 composer 下载此包

    composer update helios-ag/fm-lessql-bundle

步骤 2:启用包

最后,在 kernel 中启用此包

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new FM\LessqlBundle\FMLessqlBundle(),
    );
}

配置

您可以根据以下方式配置包

fm_lessql:
    instances:
        default:
            dsn: sqlite:%kernel.root_dir%/test.sqlite3
            username: ''
            password: ''
            options:
        mysql:
            dsn: mysql:host=localhost;dbname=testdb;charset=utf8
            username: root
            password: 12345
            options:
              'PDO::ATTR_EMULATE_PREPARES': { value: false }
              'PDO::ATTR_ERRMODE': { value: 'PDO::ERRMODE_EXCEPTION' }

##使用控制器

class AppController extends Controller
{
    /**
     * @Template()
     */
    public function indexAction()
    {

        $db = $this->get('fm_lessql.manager')->getDB('default');
        $posts = array();
        $result = $db->table_name();
        $result = $db->table( 'post' );
        $row = $result->fetch();      // fetch next row in result
        $rows = $result->fetchAll();  // fetch all rows
    }     
}

更多信息请访问 http://lessql.net/