Convert D/M/Y Date To Y/M/D Date in PHP

This is function convert form 'DD/MM/YYYY' to 'YYYY/MM/DD'
function toYMDDate($mdyDate)
        $mdyDate = explode("/",$mdyDate);
        return  implode("/",$mdyDate);
Good luck!

How To Setup SVN in BlueHost Host

1. Request bluehost for access by ssh
2. Connect to server bt ssh client (PuTTY, Bitvise)
3. Setup
~$mkdir _src
~$cd _src
_src$tar -xzvf subversion-1.4.6.tar.gz
_src$tar -xzvf subversion-deps-1.4.6.tar.gz
_src$cd subversion-1.4.6
_src/subversion-1.4.6$cd apr
_src/subversion-1.4.6/apr$./configure --enable-shared --prefix=$HOME
_src/subversion-1.4.6/apr$make && make install
_src/subversion-1.4.6/apr$cd ../apr-util
_src/subversion-1.4.6/apr-util$./configure --enable-shared --prefix=$HOME \
--with-expat=builtin --with-apr=$HOME \
_src/subversion-1.4.6/apr-util$make && make install
_src/subversion-1.4.6/apr-util$cd ../neon
_src/subversion-1.4.6/neon$EXTRA_CFLAGS="-L/usr/lib64 -fPIC"
_src/subversion-1.4.6/neon$CFLAGS="-L/usr/lib64 -fPIC"
_src/subversion-1.4.6/neon$./configure --prefix=/home/zzzzz/system --enable-shared
_src/subversion-1.4.6/neon$make && make install
_src/subversion-1.4.6/neon$cd ..
_src/subversion-1.4.6$./configure --prefix=/home/zzzzz/system --with-expat=builtin
_src/subversion-1.4.6$/$make && make install
Note : 
"~" sign represent root folder of user.
"$" sign separator execute command and folder (just type the following commands $ sign).

4. Configuration
~$nano -w .bash_profile 

(file .bash_profile in root folder. Eg: /home/bitjsc/.bash_profile)
Change this file
Change to PATH=$PATH:$HOME/bin:$HOME/system/bin
Save it(Ctrl+X)

5. Test
- Logout
- Login
- Type : svn help
- Is success?

Good luck

Introductory RIA (Rich Internet Application)

Previously when mentioned web , people understand that they are static content through a content development time was able to be customized and become "dynamic" and more interactive. Today the web has made great changes, people mention the social network interaction between people, or the "Web Application" in service jobs that would normally use independent software .
RIA is also Web applications, also run on other browsers but conventional web applications that:
- To replace partially or completely the desktop application
- Will support collaboration, sharing with users, groups of users
- Can run without internet and make updates to the server when a connection back.
Here are some example of RIA:

And in Vietnam is about to appear editing software's online lectures ftp-visky-bachkim editing software or online quiz bitjsc, editing software's online timetable of bit tech.

There are many technology what is used to create RIA applications , but the market share is critical for the Adobe Flash-Flex, Ajax-DHTML, and recently is Sliverlight of M$. The technology platform is powerful enough to create RIA applications large companies but also did not care for Vietnam. This is understandable because Vietnam mainly outsourced, now appears many companies do web 2.0 and social networking applications, but they have not seen much RIA. Technology is mainly Flash and DHTML, some companies qualified technicians to build RIA applications is not much, I know there are a few companies that are hired outsource RIA applications with DHTML Home mainly webOS (web-based operating system). Bachkim is essentially a chemical product online violet (also made of flash is primarily). BIT Inc. is mainly used Flex-Flash and a little DHTML.

RIA market, including the production and outsource currently mainly are in India's companies , if Vietnam want to join, the first must to change the way of thinking of managers,and then technical staff.

Using Element in cakePHP

Element is really necessary if we want to use a code more than once in the view or layout. Instead we have rewritten many times in the view with a similar source segment, we just write once in the elements and use them repeatedly. Creating an element used repeatedly in cakephp will be very easy when we use requestAction function. Here I will guide you to use the element that used to be in the cakephp 1.1 and 1.2.

First, we will create Post controller follows:

class PostsController extends AppController {
 var $name = 'Posts';
 function index() {
  $posts = $this->Post->findAll(); 
  //check function requestAction have been call or not
  if(isset($this->params['requested'])) {
   return $posts;
  $this->set('posts', $posts);

In Index function, we will check that it has been called by requestAciton function or not. If so, the function returns an array $ posts. Now we'll create an element post.ctp (or post.thml in cakephp 1.1) has the following path: /app/elements/posts.ctp.

 $posts = $this->requestAction('posts/index'); 
 foreach($posts as $post):
 echo $post['Post']['title'];

To use that element, we only add a paragraph code to views or layouts:

<?php echo $this->renderElement('posts');?>

Compare: PHP vs Python

I. Similar
  • They are advance language, dinamic compile and set type.
  • Open source
  • Developer community is very large
  • Easier to learn with Java, C or Perl
  • Easier to expansion with Java C++
  • Very portability, run on many platform without recompile code or fix code
II. Defference
1. Advantage of PHP:
  • PHP inherit curly braces to mark code block of C and & sign of Perl
  • switch and do...while statements
  • =, ++ and -- operator
  • ...?... : .... statement
  • Very strong array, use for list and dictionary
  • Referenced ('$a =&$b' : when $b had been change, $a will be change too)
  • There are both private, protected and public access modifiers for methods and properties
  • Using both abstract and final modifiers for classes and methods
  • Interfaces
  • $this is default object and don't need to reverse 'self' to define method as Python
  • Support to code multiline
  • Diversity comment (#, /* */ or //)
2. Advantage of Python
  • It's a language for general purpose (Python can use to make almost things, when PHP only use in web develop or console. Of cource, PHP can use in other, but it's trivial)
  • Using indentation replace curly braces to mark code block. (Of cource, it's more beautiful but it's not friendly with HTML template of Web)
  • There are namespaces and modules(PHP 5.3 have namespaces)
  • Transfer variable to function more effective than PHP by key=value pair, better support for default value of variable transfer to function
  • Apply to multi inheritance
  • Instropection better than PHP Reflection
  • Every thing from variable to object ares reference type
  • There is Threading
  • Document better than PHP (but certainly, it's less TUT, Guide, comment,... than PHP)
  • Can GUI programming (Of course PHP can but can not equal)
  • Can run on .Net with IronPython or Java platform with Jython (PHP can also run on Java, even in all of Application Server)
  • There are web server, private application server, 100% code by Python
  • There are lambdas and support functions to build functions (PHP have create_function and closure)
  • Cached byte-code (PHP also have, but not equal)
  • Support unicode better than PHP
  • Exception error control better
  • Run faster than PHP (The truth is run faster but use more CPU and RAM)

Play With RIA

What is RIA?

RIA - Rich Internet Application is a web application form (web application) try to show the traditional functions of the software running on the desktop. At any rate, the RIA erase non-state theory of the HTTP protocol.

What is feature of RIA?

  • RIA applications run entirely on the browser (web browser) supports Flash without having to install the application.
  • Using javascript to operate on various platforms (if javascript is turned off, it's will not work).
  • Performance depends on the apparatus interpreter javascript code.
  • Download capacity is large, so it depend on network.
  • Not friendly to search engines.
  • Security threats are real, although flash & javascript is very limited in intervening in the operation of the computer.
What is advantage of RIA?
  • Don't need to install or deploy, simple as running Flash applications.
  • It's provides for users with extremely diverse functions, dramatically enhancing interoperability than HTML / DHTML / Javascript tradition.
  • User interface is very impressive with attractive effects.
  • Interactive asynchronous (Asynchronous communication) with the server, reducing the use of network resources, as well as savings of server activity. Besides, easy to move data between client / server without requiring users to manipulate multiple and continuous.
How to build a RIA application?

You can use DHTML/CSS/Javascript techniques combined with traditional ajax or use 2 forms new approach rather than are Flex & Silverlight.

Simply and easiest way: you can find and download the books on the topic & tools to learn more.

If you wonder between flex & silverlight then you should learn which one? In a story with a friend a few days ago, we talked about Flash is installed on most (> 90%) current web browser, while the silverlight only ~ 6.3% is set on the number of . That means you learn flex will have a better future, you think so, right? But that day my friend ask me back an issue, if the default install Microsoft Silverlight on all versions of IE in the upcoming version of Windows, install silverlight browser market share will increase to what extent? Perhaps at about> 80% as the market share of IE today.

How To Create A Website With Cakephp

  1. Introduction
  2. Download framework
  3. Setup and configure cakePHP
    1. Setup
    2. Configure
  4. Example about using cakePHP to manage customer in application web "Manage motel".
    1. Create database
    2. Coding
    3. Operating model
    4. Model
    5. Controller
    6. View
    7. Complete all features of module "Manage motel"

1. Introduction

CakePHP is a framework for php that is to provide a framework for developer use php to progress web applications fast, powerful without losing flexibility. And the more important is cakePHP is free. You can read about it from To use it, developer must have basic knowlegde about PHP and HTML, ... You can see detail about content and some example on

2. Download Framework

Click to below link to download cakePHP framework (select stable release):

3. Setup and configure cakePHP

3.1. Setup

To use it, you need to setup some software: 
- A HTTP server (Ex : Apache, IIS) - cakePHP only support PHP version 4 or more.
- Database: cake php support database systems: MySql, PostgreSQl.

This guide based on "AppServ Version 2.5.7 for Windows" include : 
Apache Web Server Version 2.2.3
PHP Script Language Version 5.1.6
MySQL Database Version 5.0.24a
phpMyAdmin Database Manager Version

After download cakephp, you extract zip file to folder and copy to Apache Server folder.(Eg :  C:\AppServ\www\MyCake)


3.2. Configure

To cakePHP can work with database, you need to configuring database.php file, in default, this file is not exist. To configure it :
- Open database.php.default in /app/config
- Save as with name is database.php
- Change something:
var $default = array('driver' => 'mysql',
'connect' => 'mysql_connect',
'host' => 'localhost',
'login' => 'user',
'password' => 'password',
'database' => 'project_name',
'prefix' => );
With username, password is username, password to login MySql's database.
The convention of naming database table:
- Cake table name should be in the form of multiple (eg: users, customers, students ... ).
- Table must have key with name is 'id'.
- If you use relationship , foreign key have name table name (remove s) + _ + id (eg : user_id , user without s +  "_" sign + id).

After setup and configure cakePHP, check cakePHP did setup or not , you can test by opening web browser and type : http://localhost/MyCake/. Attention to 2 lines : Your database configuration file is present. Cake is able to connect to the database. Determine if you have connected to your database Cake or not.

I will talk about features, as well as the Operating model of cakePHP, how to write a web application using cakePHP through below example :

4. Using cakePHP to manage customer in web application "Manage motel".
4.1. Create database

- Create customers with fields: 

+ name : NVARCHAR
+ age : INT
+ address: NVARCHAR

- Coding : Open editor and create files with content below and save them with path :

+ customer.php -> C:\AppServ\www\MyCake\app\models\
class Customer extends AppModel
var $name = 'Customer';
+ customers_controller.php -> C:\AppServ\www\MyCake\app\controllers
class CustomersController extends AppController
var $name = 'Customers';
function index()
$this->set('customers', $this->Customer->findAll());
+ index.thtml -> C:\AppServ\www\MyCake\app\views\customers\ (create customers folder in /app/views)
<h1>Customer Manager</h1>
<?php foreach ($customers as $cust): ?>
<td><?php echo $cust['Customer']['id']; ?></td>
<?php echo $html->link($cust['Customer']['name'], '/customers/view/'.$cust['Customer']['id']);?>
<?php echo $html->link(
'Are you sure?'
<?php echo $html->link('Edit', '/customers/edit/'.$cust['Customer']['id']);?>
<td><?php echo $cust['Customer']['age']; ?></td>
<td><?php echo $cust['Customer']['address']; ?></td>
<?php endforeach; ?>
<p><?php echo $html->link("Add Customer", "/customers/add"); ?>
After complete 3 page, we are going to test . Open web browser and type :  http://localhost/MyCake/customers  you will see result. So, you created a first simple application about using cakePHP to create a web application. Next, i will explain the Operating model of cakePHP, how to create a page and how to use variable, function ...

4.2. Operating model

As i have introduced, cakePHP is a framework, so it's operating model is similar 3 classes model (MVC) in object-oriented programming. With first class is view, next is controller class and last is model class. Model class will communicate with our database.

4.4. Model

In the example shown you customer.php file with writing code as above, cakePHP will understand that we want to create a model named Customer for use in our CustomersController. The variable $name is indicated to prevent our model coincides with the name of the function of php. And the Customer class will inherit the attributes and methods of AppModel classTo be able to understand the details of the model and using the properties and functions of the model you can refer:

4.5. Controller

Controller is used to manage the communication with the database, set the desired requirements to express our view on the handler for example by adding, deleting, editing and displays, ... , is where all the activities of its management model would be. In the example above (customers_controller.php), cakePHP understand the code above is that we will create a CustomersController used to manage the use and operation of CustomerModel. Similarly, CustomersController class will inherit from AppController class. Function index() will be processed when we call index.thtml page. Including methods set() is used to assign values to an array is returned from the method FindAll() at the Customer model. In the above example, the variable $customers table will bring an array of customer value is obtained from the Customers table from the database. To view details about the controller you can refer to: 

4.6. View

View the data which has been shown by our treatment. A view is seen as a template page. We can get data from the respective model. The data is transmitted via an array $ data. In the example above, is a view index.thtml. Sequel I will talk to detail view through the example above. Next we learn to the properties and methods in index.thtml:
<? php foreach ($customers table as $cust):?>
The $customers is that we have established with the method set() in the CustomersController example. It carries an array value as I said. $html is an object of class helpers will be discussed in the next section. Method link() is used to output an link similar href in HTML with the first parameter is the title to the links, the 2nd parameter is the url.

4.7. Complete all features of module "Manage motel"

I will add the functionality to add, edit, delete, show in our view. I add in customers_controller functions as follows:
class CustomersController extends AppController{
 var $name = 'Customers';
 function index(){
  $this->set('customers', $this->Customer->findAll());
 function view($id){
  $this->Customer->id = $id;
  $this->set('customers', $this->Customer->read());
 function add(){
  if (!empty($this->data)){
   if ($this->Customer->save($this->data)){
    $this->flash('Your customer has been saved.','/customers');
 function delete($id){
  $this->flash('The customer with id: '.$id.' has been deleted.', '/customers');
 function edit($id = null){
  if (empty($this->data)){
   $this->Customer->id = $id;
   $this->data = $this->Customer->read();
   if ($this->Customer->save($this->data['Customer'])){
    $this->flash('Your customer has been updated.','/customers');
Thus we have added 4 function in our CustomersController. The function will be called in the view. For example, we clicked the link on  Add Customer,  the function will be performed and shown in our view. You create add.thtml file with the following content:
<h1>Add Customer</h1>
<form method="post" action="<?php echo $html->url('/customers/add')?>">
  <?php echo $html->input('Customer/name', array('size' => '40'))?>
  <?php echo $html->tagErrorMsg('Customer/name', 'Name is required.') ?>
  <?php echo $html->input('Customer/age', array('size' => '40'))?>
  <?php echo $html->tagErrorMsg('Customer/age', 'Age is required.') ?>
  <?php echo $html->input('Customer/address', array('size' => '40'))?>
  <?php echo $html->tagErrorMsg('Customer/address', 'Address is required.') ?>
  <?php echo $html->submit('Save') ?>
In "add" view line: 
<?php echo $html->input('Customer/name', array('size' => '40'))?>
will output a text input tag. With the command line above,  cakePHP will understand that we will use  "name" field in Customer model. The second parameter is attributes of the input tags in HTML. Similar to submit tags, TagErrorMsg() function will show the error messages in case of our data entry error. The error handling will be discussed in the following section. Similarly we create files edit.thtml, view.thtml as follows:

+ edit.thtml
<h3>Edit Your Customer</h3>
<form method="post" action="<?php echo $html->url('/customers/edit')?>">
 <?php echo $html->hidden('Customer/id'); ?>
  <?php echo $html->input('Customer/name', array('size' => '40'))?>
  <?php echo $html->tagErrorMsg('Customer/name', 'Name is required.') ?>
  <?php echo $html->input('Customer/age', array('size' => '40'))?>
  <?php echo $html->tagErrorMsg('Customer/age', 'Age is required.') ?>
  <?php echo $html->input('Customer/address', array('size' => '40'))?>
  <?php echo $html->tagErrorMsg('Customer/address', 'Address is required.') ?>
  <?php echo $html->submit('Save') ?>
+ view.thtml
<h3>Your Customer</h3>
<h1>Name :<?php echo $customers['Customer']['name']?></h1>
<h1>Age :<?php echo $customers['Customer']['age']?></h1>
<h1>Address:<?php echo $customers['Customer']['address']?></h1>
Good luck!