YiiHaa Webdevelopment blog about Yii-framework and more


Models and multiple database connections

Posted by martijn

By default, Yii uses the 'db' component for the interaction between your model and database. But Yii also supports multiple database connections. To use multiple database connections requires come configuration. In this blog I will explain how to configure multiple databases, preparing your models and use gii for creating models from all databases.


Serving large static files using Yii

Posted by Klaas

Earlier I explained how you can use X-SendFile to serve large static files more efficiently using PHP and Apache. Serving the files with PHP (and Yii) is really easy and I will explain how to do this after the break. 


Validate unique constraints with more then one attribute

Posted by martijn

Yii comes with bucket of validators including a unique validator which validates whether an attribute value is unique in the corresponding database table. But what if your database unique constraint contains more than one attribute?


CacheDependency, a real cache dependency

Posted by martijn

Using cache dependencies enables you to be in control of your cached data. Yii provides several dependency methods such as database, file and globalState.

They all work fine but when I use memcached as caching provider, I do not want Yii to check dependencies located on the hard drive everytime Yii::app()->cache->get() is called


Minify and merge your CSS and JavaScript

Posted by Klaas

It is good practice to optimize CSS and JavaScript for lower load time, it is never good to have a lot of <link ref="stylesheet" href="...> or <script src="...> tags in <head>.