The set_time_limit() function enables the setting the timeout for the browser. The following snippet set the time out for 15 minutes / 900 seconds set_time_limit(900); The default time limit is 30 seconds or max_execution_time value available in php.ini file.
Friday, May 27, 2011
Thursday, May 26, 2011
Explain about type Juggling with an example in php?
7:28 PM
No comments
PHP does not require (or support) explicit type definition in variable declaration; a variable's type is determined by the context in which that variable is used. That is to say, if you assign a string value to variable $var, $var becomes a string. If you then assign an integer value to $var, it becomes an integer.
An example of PHP's automatic type conversion is the addition operator '+'. If any of the operands is a float, then all operands are evaluated as floats, and the result will be a float. Otherwise, the operands will be interpreted as integers, and the result will also be an integer. Note that this does NOT change the types of the operands themselves; the only change is in how the operands are evaluated.
$foo += 2; // $foo is now an integer (2)
$foo = $foo + 1.3; // $foo is now a float (3.3)
$foo = 5 + "10 Little Piggies"; // $foo is integer (15)
$foo = 5 + "10 Small Pigs"; // $foo is integer (15)
If the last two examples above seem odd, see String conversion to numbers.
If you wish to change the type of a variable, see settype().
If you would like to test any of the examples in this section, you can use the var_dump() function.
Note: The behavior of an automatic conversion to array is currently undefined.
Since PHP (for historical reasons) supports indexing into strings via offsets using the same syntax as array indexing, the example above leads to a problem: should $a become an array with its first element being "f", or should "f" become the first character of the string $a? The current versions of PHP interpret the second assignment as a string offset identification, so $a becomes "f", the result of this automatic conversion however should be considered undefined. PHP 4 introduced the new curly bracket syntax to access characters in string, use this syntax instead of the one presented above:
An example of PHP's automatic type conversion is the addition operator '+'. If any of the operands is a float, then all operands are evaluated as floats, and the result will be a float. Otherwise, the operands will be interpreted as integers, and the result will also be an integer. Note that this does NOT change the types of the operands themselves; the only change is in how the operands are evaluated.
$foo += 2; // $foo is now an integer (2)
$foo = $foo + 1.3; // $foo is now a float (3.3)
$foo = 5 + "10 Little Piggies"; // $foo is integer (15)
$foo = 5 + "10 Small Pigs"; // $foo is integer (15)
If the last two examples above seem odd, see String conversion to numbers.
If you wish to change the type of a variable, see settype().
If you would like to test any of the examples in this section, you can use the var_dump() function.
Note: The behavior of an automatic conversion to array is currently undefined.
Since PHP (for historical reasons) supports indexing into strings via offsets using the same syntax as array indexing, the example above leads to a problem: should $a become an array with its first element being "f", or should "f" become the first character of the string $a? The current versions of PHP interpret the second assignment as a string offset identification, so $a becomes "f", the result of this automatic conversion however should be considered undefined. PHP 4 introduced the new curly bracket syntax to access characters in string, use this syntax instead of the one presented above:
Wednesday, May 25, 2011
Explain the capabilities of views module in Drupal.
12:14 AM
No comments
The Views module provides a flexible method for Drupal site designers to control how lists and tables of content (nodes in Views 1, almost anything in Views 2) are presented. Traditionally, Drupal has hard-coded most of this, particularly in how taxonomy and tracker lists are formatted.
This tool is essentially a smart query builder that, given enough information, can build the proper query, execute it, and display the results. It has four modes, plus a special mode, and provides an impressive amount of functionality from these modes.
Among other things, Views can be used to generate reports, create summaries, and display collections of images and other content.
This tool is essentially a smart query builder that, given enough information, can build the proper query, execute it, and display the results. It has four modes, plus a special mode, and provides an impressive amount of functionality from these modes.
Among other things, Views can be used to generate reports, create summaries, and display collections of images and other content.
Saturday, May 14, 2011
Explain Taxonomy in drupal
10:53 PM
No comments
Drupal has a system for classifying content, which is known as taxonomy and implemented in the core Taxonomy module. You can define your own vocabularies (groups of taxonomy terms), and add terms to each vocabulary. Vocabularies can be flat or hierarchical, can allow single or multiple selection, and can also be "free tagging" (meaning that when creating or editing content, you can add new terms on the fly). Each vocabulary can then be attached to one or more content types, and in this way, nodes on your site can be grouped into categories, tagged, or classified in any way you choose.
Explain the concept of Comment in Drupal
10:50 PM
No comments
Comments are another type of content you can have on your site (if you have enabled the core Comment module). Each comment is a typically small piece of content that a user submits, attached to a particular node. For example, each piece of discussion attached to a particular forum topic node is a comment.
Thursday, May 12, 2011
How can you include a javascript menu throughout the site in cakephp?
5:57 PM
No comments
By adding the javascript files in webroot and call them in default views if needed everywhere or just in the related views.
How can you make urls search engine friendly while using cakephp?
5:56 PM
No comments
It is an automatic task that is done by cakephp.
Monday, May 9, 2011
How can we use ajax in cakephp?
6:39 PM
No comments
By calling ajax helper and then using it in controller for rendering
Can you remember what is the directory structure when you download cakephp?
6:37 PM
No comments
* app/
o config/
o controllers/
o models/
o plugins/
o tmp/
o vendors/
o views/
o webroot/
* cake/
o config/
o docs/
o libs/
* vendors/
o config/
o controllers/
o models/
o plugins/
o tmp/
o vendors/
o views/
o webroot/
* cake/
o config/
o docs/
o libs/
* vendors/
Can you list some database related functions in cakephp?
6:37 PM
No comments
find, findAll , findAllBy , findBy , findNeighbours , query
Saturday, May 7, 2011
What are the different types of index in mysql?
5:20 PM
No comments
The different types of index are UNIQUE, INDEX and FULLTEXT
How do you proceed when you have to use cakephp for any application?
9:19 AM
No comments
Take the framework either from cake site or if you have changed according to your needs start from there. proceed with basic software engg. concepts as requirement gathering etc
If you have to validate a registration module for a user, what all can be possible ways? which one is the best?
9:17 AM
No comments
Can be done on submission in controller, or using javascript/ajax while user is still filling the data. second option is better.
Using cakephp, what all are drawbacks?
9:17 AM
No comments
The learning curve, and it loads full application before it starts your task. Its not recommended for small projects because of its resource heavy structure.
What are 3 important parts of MVC (MODEL-VIEW-CONTROLLER)?
9:16 AM
No comments
1. The Model represents the application data
2. The View renders a presentation of model data
3. The Controller handles and routes requests made by the client
2. The View renders a presentation of model data
3. The Controller handles and routes requests made by the client
What is a component, helper and why are they used, is there other way we can do same thing, what is better?
9:12 AM
No comments
A component is an independent piece of code written for specific task that can be used by calling in controllers (example : email component), helper is used for helping cakephp in rendering the data to be shown to user with views, these only adds to modularity in code otherwise same coding can be implemented in controllers.
What is features in cake php?
9:09 AM
No comments
list some of the features in Cake php
1. Compatible with versions 4 and 5 of PHP
2. MVC architecture
3. Built-in validations
4. Caching
5. scaffolding
Scaffolding is a meta-programming method of building database-backed software applications. It is a technique supported by some model-view-controller frameworks, in which the programmer may write a specification that describes how the application database may be used. The compiler uses this specification to generate code that the application can use to create, read, update and delete database entries, effectively treating the template as a "scaffold" on which to build a more powerful application.
1. Compatible with versions 4 and 5 of PHP
2. MVC architecture
3. Built-in validations
4. Caching
5. scaffolding
Scaffolding is a meta-programming method of building database-backed software applications. It is a technique supported by some model-view-controller frameworks, in which the programmer may write a specification that describes how the application database may be used. The compiler uses this specification to generate code that the application can use to create, read, update and delete database entries, effectively treating the template as a "scaffold" on which to build a more powerful application.
What is habtm?
9:08 AM
No comments
Has and belongs to many is a kind of associations that can be defined in models for retrieving associated data across different entities.
Friday, May 6, 2011
What is meant by MVC (MODEL-VIEW-CONTROLLER)?
10:19 PM
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 is the first file that gets loaded when you run an application using cakephp?
9:59 PM
No comments
bootstrap.php , it can be changed , either through index.php , or through .htaccess
What is the naming convention in cakephp?
8:04 PM
No comments
Table names are plural and lowercased,model names are singular and CamelCased:ModelName, model file names 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 keys should always be: table_name_in_singular_form_id: user_id (foreign key) → users (table) , many-to-many join tables should be named: alphabetically_first_table_plural_alphabetically_second_table_plural: tags_users , columns in many-to-many join tables should be named like other foreign keys: tag_id and user_id , columns named “created” and “modified” will automatically be populated correctly
what is cakephp?
11:27 AM
No comments
Cakephp is a rapid development framework for PHP that provides an extensible architecture for developing, maintaining, and deploying applications. it uses commonly known design patterns like MVC,ORM within the convention over configuration paradigm, It also reduces development costs and helps developers write less code.
what is the name of Cake's database configuration file?
11:26 AM
No comments
By default it is database.php.default, you can find it in /app/config/database.php.default
for connecting to database, it should be renamed to database.php
for connecting to database, it should be renamed to database.php
Explain MVC Architecture in Php with example
11:26 AM
25 comments
Model-View-Controller is the concept introduced by Smalltalk's inventors to encapsulating some data together with its processing (the model) and isolate it from the manipulation (the controller) and presentation (the view) part that has to be done on a UserInterface.
A model :- is an object representing data e.g. a database table.
A view :- is some form of visualization of the state of the model.
A controller :- offers facilities to change the state of the model.
<?php
//////////////My Property Class////////////
// it contain getter setter function
abstract class EmployeeProperty
{
private $deptid;
public function getDeptId() //Getter
{
return $this->deptid;
}
public function setDeptId($id) //setter
{
$this->deptid=$id;
}
}
//////////My Interface /////////
interface iEmployee
{
function getEmployeeName(EmployeeProperty $objEmployeeProperty);
}
/////////My Data access layer//////
// it fetch data from database server
//it model part of mvc
class DALEmployee implements iEmployee
{
public function getEmployeeName(EmployeeProperty $objEmployeeProperty)
{
$con = mysql_connect("localhost","root","root"); //open connection
if (!$con)
{
die('Could not connect to mysql ' . mysql_error()); // error message
}
else
{
mysql_select_db("test",$con); // select database
$result= mysql_query("select emp_name from employee where deptid=".$objEmployeeProperty-> getDeptId()); // fire query
mysql_close($con); // close connection
}
return $result;
}
}
///////////My business logic layer////////
// it is controller part of mvc
class BALEmployee extends EmployeeProperty
{
public function getEmployeeName(EmployeeProperty $objEmployeeProperty)
{
$objiEmployee=new DALEmployee();
return $objiEmployee->getEmployeeName($objEmployeeProperty);
}
}
?>
/////////////////////My View Part///////////////////////////////////////
New Document
<?php
include("Employee.php");
///////////////My View Part//////////////////
$objBALEmployee=new BALEmployee(); //Create object of business logic layer
$objBALEmployee->setDeptId(1); // Set Property
$result= $objBALEmployee->getEmployeeName($objBALEmployee); // excess bll function
while($row = mysql_fetch_row($result)) // fetch result
{
echo $row[0].""; // display result
}
?>
A model :- is an object representing data e.g. a database table.
A view :- is some form of visualization of the state of the model.
A controller :- offers facilities to change the state of the model.
<?php
//////////////My Property Class////////////
// it contain getter setter function
abstract class EmployeeProperty
{
private $deptid;
public function getDeptId() //Getter
{
return $this->deptid;
}
public function setDeptId($id) //setter
{
$this->deptid=$id;
}
}
//////////My Interface /////////
interface iEmployee
{
function getEmployeeName(EmployeeProperty $objEmployeeProperty);
}
/////////My Data access layer//////
// it fetch data from database server
//it model part of mvc
class DALEmployee implements iEmployee
{
public function getEmployeeName(EmployeeProperty $objEmployeeProperty)
{
$con = mysql_connect("localhost","root","root"); //open connection
if (!$con)
{
die('Could not connect to mysql ' . mysql_error()); // error message
}
else
{
mysql_select_db("test",$con); // select database
$result= mysql_query("select emp_name from employee where deptid=".$objEmployeeProperty-> getDeptId()); // fire query
mysql_close($con); // close connection
}
return $result;
}
}
///////////My business logic layer////////
// it is controller part of mvc
class BALEmployee extends EmployeeProperty
{
public function getEmployeeName(EmployeeProperty $objEmployeeProperty)
{
$objiEmployee=new DALEmployee();
return $objiEmployee->getEmployeeName($objEmployeeProperty);
}
}
?>
/////////////////////My View Part///////////////////////////////////////
New Document
<?php
include("Employee.php");
///////////////My View Part//////////////////
$objBALEmployee=new BALEmployee(); //Create object of business logic layer
$objBALEmployee->setDeptId(1); // Set Property
$result= $objBALEmployee->getEmployeeName($objBALEmployee); // excess bll function
while($row = mysql_fetch_row($result)) // fetch result
{
echo $row[0].""; // display result
}
?>
Subscribe to:
Posts (Atom)