sadapon2008/mysql_collate

There is no license information available for the latest version (0.2) of this package.

Mysql Datasource For CakePHP supporting COLLATE in conditions

0.2 2015-02-20 05:08 UTC

This package is not auto-updated.

Last update: 2024-04-23 01:45:28 UTC


README

Mysql datasource for CakePHP 2.x supporting COLLATE in conditions.

Example

1. change datasource in database.php

public $default = array(
    'datasource' => 'MysqlCollate.Database/MysqlCollate',
    'persistent' => false,
    'host' => 'localhost',
    'port' => '',
    'login' => 'cakeBlog',
    'password' => 'c4k3-rUl3Z',
    'database' => 'cake_blog_tutorial',
    'schema' => '',
    'prefix' => '',
    'encoding' => 'utf8'
);

2. load MysqlCollateBehavior before Model::find()

$options = array(
    'condition' = array(
        'Post.title LIKE' => 'aBcD',
    ),
    'order' => array(
        'Post.id' => 'ASC',
    ),
);

$this->Post->Behaviors->load(
    'MysqlCollate.MysqlCollate',
    array(
      'Post.title' => 'utf8_unicode_ci',
    )
);

$result = $this->Post->find('all', $options);

$this->Post->Behaviors->unload('MysqlCollate');