Skip to content

sadapon2008/mysql_collate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

MysqlCollate

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');

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages