Alba HK

Chinese Characters with Propel ORM

After walking through the Propel ORM tutorial on building a project my app could not display Chinese characters (UTF-8) correctly. Instead of characters I was getting “????”. I confirmed the columns in the DB were in UTF-8 format and viewed the data in another program – it checked out ok. I double checked the database encoding/collation and it was correctly set to UTF-8/Unicode. The individual table and column were also set for UTF-8 – its important to check this since some MySQL installations may default to latin1 which will not work with any non-english characters.

The solution for my problem turned out to be adding a few lines in the runtime-conf.xml file. The build tutorial in the Propel tutorial shows a standard runtime-conf.xml file but does not include an optional configuration parameter for the encoding on the DB connection. Below is the standard file with the encoding option added for UTF8 in bold:

<?xml version="1.0" encoding="UTF-8"?>
<config>
  <!-- Uncomment this if you have PEAR Log installed
  <log>
    <type>file</type>
    <name>/path/to/propel.log</name>
    <ident>propel-bookstore</ident>
    <level>7</level>
  </log>
  -->
  <propel>
    <datasources default="bookstore">
      <datasource id="bookstore">
        <adapter>mysql</adapter> <!-- sqlite, mysql, mssql, oracle, or pgsql -->
        <connection>
          <dsn>mysql:host=localhost;dbname=my_db_name</dsn>
          <user>my_db_user</user>
          <password>my_db_password</password>
          <settings>
            <setting id="charset">utf8</setting>
          </settings>
        </connection>
      </datasource>
    </datasources>
  </propel>
</config>

After the making the above changes I could get Chinese characters correctly displaying in my app.

Building an invoice-focused business

Moving into the fourth week of full-time work on a new business I am concerned at how easily distractions can creep into my day and pull me away from my work. Until now I have forced myself to do a quick evaluation by asking myself the following question: “Does this task bring me closer to writing an invoice for a new client?” If the answer is no, then I stop and move to a task that does.

Continue reading

MAMP and Virtual hosts on Mac OS

I’ve just spent a few hours setting up a new local development environment for development and thought I would write down the steps both for my own reference and hopefully for the benefit of others using MAMP.

Development Environment

We are using a Mac OS X environment for development. Basically all our projects are under version control (SVN) and we use MAMP to get the basic web development stack up and running with as little drama as possible. We use the command-line or svnX for SVN and Textmate for code. It’s relatively problem-free to setup and most importantly gets out of our way so we can get on with real work rather than faffing about with configurations and Yak shaving.

Multiple Projects under MAMP

Often we’ve got multiple projects underway and while MAMP is great out of the box for a single site, shutting down and restarting it with a new DocumentRoot was not a satisfactory solution for switching between projects, not to mention embarrassingly low-tech.
Continue reading