Monday, January 17, 2011

SEO TIPS AND Cake PHP INTERVIEW QUESTIONS: INTERVIEW QUESTIONS OF Cakephp WITH ANSWER

1.What is the correct model association for the below database tables: Table 1 - Catalogs ------------------ id catalog_name description Table 2 - Books ------------------ id book_name title description catalog_id

Ans:Book BelongsTo Catalog and Catalog HasMany Book


2. Identify the correct format for defining paginaton in the controller

Ans:this->paginate = array( 'conditions' => array('Book.title LIKE' => 'a%'),'limit' => 10)

3.Select the correct explanation for Scaffolding in Cakephp

Ans:Scaffolding is a technique that allows a developer to define and create a basic application that can create, retrieve, update and delete objects.

4.Select the option below that best defines the controller in a Cakephp application.

Ans:A controller is used to manage the logic for a part of your application usually a model.

5.What are Helpers used in Cakephp applications?

Ans:Contain presentational logic that is shared between many views, elements, or layouts.

6.A model usually represents a database table but can be used to access anything that stores data such as files, LDAP records, iCal events, or rows in a CSV file. Is this True?

Ans:Yes

7.For storing data to a cakephp model, data ready to be saved should be passed to the model's which method?

Ans:save

8.As per cakephp convention, select the correct naming convention for the controller, model and view , and their files if the database table name is book_reviews and the controller has a method called “find_book”.

Ans:Controller – BookReviewsController, File – book_reviews_controller.php , Model – BookReview, File – book_review.php, View File – find_book.ctp

9.Select the syntax for a find query in cakephp, that gets the first record where active status is not equal to 'N' and id=1.

Ans:$query = $this->Article->find('first', array('conditions' => array('Article.id' => 1 , 'NOT' => array('TeamTechmapping.status' => 'N' )));

10.Select the level of model recursion such that cake fetches Group, its domain and its associated Users.

Ans:1
11. If you would like to validate the fields before saving the data, such as checking for numeric data or validating email format etc, where will you ideally define this check

Ans:Model

12.For the Ajaxhelper to work in Cakephp, the Javascript libraries required are _______ and ________, and they need to be placed in __________

Ans:prototype , scriptaculous , /app/webroot/js/

13.Which of the following is NOT a controller attribute.

Ans:displayField

14.Elements in Views are:

Ans:Reusable parts or blocks of presentation code that can be called from any view , layout, or other elements.

15.Choose the line to define the default layout as “default_layout” in the controller.

Ans: $this->layout = 'default_layout';

16.Select the correct choice that defines a component, helper and behaviour in Cakephp

Ans: Component is a Controller extension, Helpers are View extensions, Behavior is a Model Extension.

17.Out of the files/folders here, select the one that you will NOT SEE in the root folder of a Cakephp application.

Ans:tmp

19.Which Ajax method below returns a link to a remote action that's called in the background using XMLHttpRequest when the link is clicked

Ans:link

20.The method used to write a value 'Test' to the Session variable 'User.username' in cakephp is

Ans:$this->Session->write('User.username', 'Test')

21.The _____________ method will delete the session cookie and all session data stored in the temporary file system.

Ans: destroy

22.The _____________ function is executed before every action in the controller.

Ans:beforeFilter

23.The method requestAction is used to

Ans:calls a controller's action from any location and returns data from the action

24.The four model association types in CakePHP are

Ans:hasOne, hasMany, belongsTo, and hasAndBelongsToMany

25.bindModel() and unbindModel() Model methods are used to

Ans:Create and destroy model associations on the fly

No comments: