Archive for the ‘cakePHP Interview Questions’ Category

Magical Feature of cakePHP – findBy

Wednesday, March 17, 2010 13:39 No Comments

These magic functions can be used as a shortcut to search your tables by a certain field. Just add the name of the field (in CamelCase format) to the end of these functions, and supply the criteria for that field as the first parameter.
PHP5 findBy Example

$this->Product->findByOrderStatus(‘3′); //Product.order_status = 3
$this->Recipe->findByType(‘Cookie’); //Recipe.type = ‘Cookie’
$this->User->findByLastName(‘Anderson’); //User.last_name = ‘Anderson’
$this->Cake->findById(7); [...]

This was posted under category: cakePHP Interview Questions

What is meant by MVC ? cakePHP interview Question

Wednesday, March 10, 2010 9:46 No Comments

MODEL VIEW CONTROLLER, it is a software architecture, used to isolates business logic from presentation logic. cakephp is based on mvc pattern.
What are 3 important parts of MVC?
1. The Model represents the application data
2. The View renders a presentation of model data
3. The Controller handles and [...]

This was posted under category: cakePHP Interview Questions

Explain about the naming Conventions in cakePHP – cakePHP Interview Question

Tuesday, March 2, 2010 16:43 No Comments

Table names are plural and lowercased.
Model names are singular and CamelCased: ModelName.
Model filenames are singular and underscored: model_name.php.
Controller names are plural and CamelCased with *Controller* appended: ControllerNamesController.
Controller filenames are plural and underscored with *controller* appended: controller_names_controller.php
Associations should use the ModelName, and the order should match the order of the foreignKeys: var $belongsTo = ‘User’;
Foreign [...]

This was posted under category: cakePHP Interview Questions

The role of CakePHP

Monday, February 22, 2010 21:38 1 Comment

CakePHP was critical to the project’s success. Here I emphasize what we consider are some of the main advantages to using the Framework.

It offers many useful, ready-to-use tools. CakePHP prevents us from having to “reinvent the wheel” every time. For common problems that must be solved when using an application of medium complexity, CakePHP already [...]

This was posted under category: cakePHP Interview Questions

CakePHP : Change view file from controller

Monday, February 22, 2010 21:08 No Comments

With CakePHP, the controller core automatically detects the file name of the view file which needs to be rendered from a controller action. You might want to reuse an existent view for an action or specify a different file name.
For example, if you have a controller named “Users” and you execute a controller action named [...]

This was posted under category: cakePHP Interview Questions

CakePHP : SELECT BETWEEN query syntax

Sunday, February 21, 2010 19:06 No Comments

return $this->LogfileRecord->find(‘all’, ‘conditions’ => array(‘LogfileRecord.date between ? and ?’ => array($start_date, $end_date)));

This was posted under category: cakePHP Interview Questions

ife (ifempty) function with clearbox in cakePHP

Monday, February 15, 2010 13:31 No Comments

I use it in this way.

//If member_image will empty then set ‘no-photo.jpg’ as default image

$thumb_photo = ife($member['Member']['member_image'], $member['Member']['member_image'], "no-photo.jpg");

Optional:
Then call it in the image tag and apply clearbox if you want;

<a rel="clearbox" href="<?php echo $GLOBALS['ABSOLUTE']['PATH'];?>/img/members_photos/<?php echo $thumb_photo;?>" target="_blank">

<?php echo $html->image(‘members_photos/thumbs/’.$thumb_photo, array(‘alt’ => ”, ‘border’ => ‘0′, ‘width’ => ‘141′, ‘height’ => ‘137′));?>

</a>

This was posted under category: cakePHP Interview Questions

fileExistsInPath cakePHP function to check if File/Image Exists in valid Path

Saturday, February 13, 2010 13:01 No Comments

function deletephotograph($id){
//Get File/Image name
$data = $this->Propphotograph->find(‘first’, array(‘conditions’ => array(‘Propphotograph.id’ => $id), ‘fields’ => array(‘Propphotograph.photograph’)));
$image_name = $data['Propphotograph']['photograph'];

// Use fileExistsInPath() function to check valid File/Image Path
$thumbPath = ‘img/props_photographs/thumbs/’.$image_name.”;
$imagePath = ‘img/props_photographs/’.$image_name.”;
if (fileExistsInPath($imagePath)){unlink($imagePath);} // Delete Image if it exists
if (fileExistsInPath($thumbPath)){unlink($thumbPath);} // Delete Image Thumb [...]

This was posted under category: cakePHP Interview Questions

Inserting multiple rows in cakephp

Wednesday, February 10, 2010 13:15 1 Comment

I had a situation where I needed to iterate through a list of items and insert new rows for each. I quickly discovered that if you insert an item and then immediately insert another, the item that is inserted next doesn’t insert at all. Instead the previously inserted row was being updated. For example:
$items = [...]

This was posted under category: cakePHP Interview Questions

The cake is still rising

Thursday, February 4, 2010 23:44 No Comments

Recent weeks have seen a few changes in the development team, as well as some clarification of the roadmap for CakePHP future releases. We’d like to thank those leaving for all their hard work and contributions. For those sticking around, you are in for a treat!
CakePHP Project Manager Garrett Woodworth and Developer Nate Abele have [...]

This was posted under category: cakePHP Interview Questions