Posts under PHP

Symfony: Control Model->save() function to perform INSERT or UPDATE

advertisement

In Symfony Framework, Model->save() function is clever enough to determine to use INSERT or UPDATE for the query. But i’ve tried many ways to perform an UPDATE for my record but failed. It keep INSERT new record. Finally i found the solution to control the Model->save() function to perform INSERT or UPDATE.

Just a simple example:-
Assume there is a User table where ID is the primary key, and there is a user record with id = 5, now we perform the code below, it should be smart enough to perform UPDATE but NO!, the code below will INSERT a new record.

Continue reading Symfony: Control Model->save() function to perform INSERT or UPDATE »

PHP: How to convert ISO character (HTMLEntities) to UTF-8?

advertisement

convert htmlentities to utf8, convert iso to utf8, convert string to utf-8, convert string to utf8, php character encoding problem, php convert iso to utf8, php how toI’m facing problem in how to convert string from ISO to UTF8 previously. Due to the server configuration problem, all the UTF-8 char has been convereted into ISO (HTMLEntities) before it insert into db and those ISO character (HTMLEntities) break while showing in XML document. Now i found the solution to convert ISO character into UTF-8.

The original utf-8 chinese words: “你好”.
Converted to ISO (HTMLEntities) : “你好”

For you to convert the ISO string “你好” to become utf-8 chinese words: “你好”, you need to use Multibyte String function (or mbstring extension). Example below uses mb_convert_encoding function to convert ISO (HTMLEntities) characters to UTF-8:-

Continue reading PHP: How to convert ISO character (HTMLEntities) to UTF-8? »

Install eAccelerator to Optimize PHP performance

advertisement

php, php cache, php accelerator, php tuningServer load increase? looking for ways to optimize your php performance? if you have php optimization problem, you should try PHP eAccelerator. PHP eAccelerator is a free open source PHP accelerator, optimizer and dynamic content cache module that specially build to optimize php performance. According to php eaccelerator official site, php accelerator able to speed up the php code by 1-10 times and reduce server load.

How PHP eAccelerator able to speed up php code and reduce server load?

PHP eAccelerator works this way, whenever there is request to a file, PHP eAccelerator will parse the php file and cache them in their compiled state in the shared memory. So when the next request come, php eAccelerator will serve the request using the cache and it completely eliminated the compile state, so it will speed up php execution. (*Files that can’t fit in shared memory are cached on disk only.)

Interested with PHP eAccelerator? How to install PHP eAccelerator?

Continue reading Install eAccelerator to Optimize PHP performance »