Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9182709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:37:28+00:00 2026-06-17T18:37:28+00:00

I’m using Symfony 2.1.6 framework integrated with Propel 1.6.7 as database ORM through a

  • 0

I’m using Symfony 2.1.6 framework integrated with Propel 1.6.7 as database ORM through a MySQL Server 5.5.28 and I’m having problem to set database collation to utf8_unicode_ci.

My app/config/config.yml:

...
propel:
    dbal:
        driver:               %database_driver%
        user:                 %database_user%
        password:             %database_password%
        dsn:                  "%database_driver%:host=%database_host%;dbname=%database_name%;charset=%database_charset%"
        options:
            MYSQL_ATTR_INIT_COMMAND: "SET NAMES utf8 COLLATE utf8_unicode_ci"
        attributes:           {}

(parameters are already defined in app/config/parameters.yml)

Without options it works, but with charset issues (MySQL defaults to utf8_general_ci collation, but database schema was defined with utf8_unicode_ci). If I use options as above Propel/Symfony raise a bunch of exceptions:

in /var/www/vendor/propel/propel1/runtime/lib/Propel.php at line 725  -+
at ErrorHandler ->handle ('2', 'Illegal string offset 'value'', '/var/www/vendor/propel/propel1/runtime/lib/Propel.php', '725', array('source' => array('MYSQL_ATTR_INIT_COMMAND' => 'SET NAMES utf8 COLLATE utf8_unicode_ci'), 'write_to' => array(), 'option' => 'MYSQL_ATTR_INIT_COMMAND', 'optiondata' => 'SET NAMES utf8 COLLATE utf8_unicode_ci', 'key' => '1002'))
in /var/www/vendor/propel/propel1/runtime/lib/Propel.php at line 725  -+
at Propel ::processDriverOptions (array('MYSQL_ATTR_INIT_COMMAND' => 'SET NAMES utf8 COLLATE utf8_unicode_ci'), array())
in /var/www/vendor/propel/propel1/runtime/lib/Propel.php at line 668  -+
at Propel ::initConnection (array('dsn' => 'mysql:host=127.0.0.1;dbname=symfony;charset=utf8', 'user' => 'root', 'password' => '********', 'classname' => 'DebugPDO', 'options' => array('MYSQL_ATTR_INIT_COMMAND' => 'SET NAMES utf8 COLLATE utf8_unicode_ci'), 'attributes' => array(), 'settings' => array()), 'default')
in /var/www/vendor/propel/propel1/runtime/lib/Propel.php at line 576  -+
at Propel ::getMasterConnection ('default')
in /var/www/vendor/propel/propel1/runtime/lib/Propel.php at line 602  -+
at Propel ::getSlaveConnection ('default')
in /var/www/vendor/propel/propel1/runtime/lib/Propel.php at line 552  -+
at Propel ::getConnection ('default', 'read')
in /var/www/vendor/propel/propel1/runtime/lib/query/ModelCriteria.php at line 1160  -+
at ModelCriteria ->find ()
in /var/www/src/Acme/AppBundle/Controller/DefaultController.php at line 20  -+
at DefaultController ->fooAction ()
at call_user_func_array (array(object(DefaultController), 'fooAction'), array())
in kernel.root_dir/bootstrap.php.cache at line 1426  -+
at HttpKernel ->handleRaw (object(Request), '1')
in kernel.root_dir/bootstrap.php.cache at line 1390  -+
at HttpKernel ->handle (object(Request), '1', true)
in kernel.root_dir/bootstrap.php.cache at line 1566  -+
at HttpKernel ->handle (object(Request), '1', true)
in kernel.root_dir/bootstrap.php.cache at line 617  -+
at Kernel ->handle (object(Request))
in /var/www/web/app_dev.php at line 25  -+

I know that I can change my.cnf to define MySQL default collation directly from server config, but I need to set this at runtime… Am I missing something? How I should set MYSQL_ATTR_INIT_COMMAND in app/config/config.yml?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T18:37:29+00:00Added an answer on June 17, 2026 at 6:37 pm

    If you see source code here,

    $value = $optiondata['value']; // this is line no 275
    if (is_string($value) && strpos($value, '::') !== false) {
        if (!defined($value)) {
           throw new PropelException("Invalid PDO option/attribute value specified: ".$value);
        }
        $value = constant($value);
    }
    

    Its expecting an “value” key in option data, so try this

    propel:
        dbal:
            driver:               %database_driver%
            user:                 %database_user%
            password:             %database_password%
            dsn:                  "%database_driver%:host=%database_host%;dbname=%database_name%;charset=%database_charset%"
            options:
                MYSQL_ATTR_INIT_COMMAND: { value: "SET NAMES utf8 COLLATE utf8_unicode_ci" }
            attributes:           {}
    

    Or

    you can also define queries which has to be executed immediately after connection opened

    propel:
        dbal:
            default_connection:         default
            connections:
                default:
                    # ...
                    options:
                        ATTR_PERSISTENT: false
                    attributes:
                        ATTR_EMULATE_PREPARES: true
                    settings:
                        charset:        { value: UTF8 }
                        queries:        { query: 'INSERT INTO BAR ('hey', 'there')' }
    

    FYI: https://github.com/propelorm/PropelBundle/blob/1.1/Resources/doc/configuration.markdown

    Propel runtime configuration file

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
We're building an app, our first using Rails 3, and we're having to build
I've tracked down a weird MySQL problem to the two different ways I was
Let's say I'm outputting a post title and in our database, it's Hello Y’all
I am using JSon response to parse title,date content and thumbnail images and place
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
I am using the SimpleRSS gem to parse a WordPress RSS feed. The only
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.