iakumai/doctrine-functions 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

iakumai/doctrine-functions

Composer 安装命令:

composer require iakumai/doctrine-functions

包简介

Doctrine DQL Functions for Mysql

README 文档

README

This package contains some doctrine functions

String functions

DateTime functions

Math functions

  • RAND() - documentation. Remember, you can not use parameters in this function.
  • RANDP(12345) - documentation. This is still RAND() MySQL function, but you must use a number parameter in it.

Installation

Just add the package to your composer.json

{
    "require": {
        "iakumai/doctrine-functions": "dev-master"
    }
}

Integration

1) Doctrine Only

According to the Doctrine documentation you can register the functions in this package this way.

<?php
$config = new \Doctrine\ORM\Configuration();
$config->addCustomDatetimeFunction('instr', 'IAkumaI\DQL\Str\Instr');
?>

2) Using Symfony 2

With symfony 2 you can register yout functions in the config.yml file.

doctrine:
    orm:
        entity_managers:
            default:
                dql:
                    datetime_functions:
                        instr: IAkumaI\DQL\Str\Instr

Usage

Simple example, usage a DateFormat function:

<?php
use Doctrine\ORM\EntityManager;

// EntityManager
$em->createQuery("SELECT DATE_FORMAT(e.date, '%d.%m.%Y') as df FROM YourBundle:Ent e");
?>

This way you can use DQL function in ORDER statement. For example, order by RAND():

<?php
use Doctrine\ORM\EntityManager;

// EntityManager
$em->createQuery("SELECT e, RAND() as HIDDEN rand FROM YourBundle:Ent e ORDER BY rand");
?>

统计信息

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

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2013-10-09

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固