Archive for March, 2009
What is the naming convention in cakephp? cakePHP Interview Question
on March 31, 2009
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 keys should always …
PHP Advantages
on March 31, 2009
PHP is a useful programming language because it allows for advanced programming and is easy to integrate with web pages. Another and of PHP is that the language interfaces well with MySQL, a popular type of online database. MYSQL is a commercial grade database application that is made available free under the Open Source to someone. Another and of PHP is that it …
How to Submit a form post with PHP and CURL?
on March 30, 2009
The PHP CURL functions use the libcurl library to allow you to connect to various servers and different protocols. This post shows how to make an HTTP POST with PHP and CURL passing several form fields. This can be useful for testing your own web forms, connecting to APIs that require POST data and so on. The PHP Code The following PHP code …
POST in multipart/form-data mode using CURL PHP
on March 29, 2009
<?php curl_setopt($ch,CURLOPT_POSTFIELDS,$post); ?> where $post is an array : <?php $post['key1'] = ‘data1′; // like a text field in a POST $post['file1'] = ‘@filename1′ // upload filename1 ?>
Viewing the SQL queries that are running behind the scenes
on March 29, 2009
You can easily see the SQL queries that CakePHP is running by adjusting the DEBUG constant in config/core.php. 0 is production, 1 is development, 2 is full debug with SQL, and 3 is full debug with SQL and dump of the current object. I typically have debug set at 2, which renders a table at the bottom of the page that contains SQL …
Simple Javascript Form Validation
on March 29, 2009
<html> <head> <title>Javascript Form Validation</title> <script type=’text/JavaScript’> function validate() { if(document.form1.textinput.value==”) { alert(‘Fill the Input box before submitting’); return false; } else { return true; } } </script> </head> <body> <form name=’form1′ action=’javascript_validation.php’ method=’post’ onSubmit=’return validate();’> <input type=text name=textinput value=”> <input type=submit value=submit> </form> </body> </html>
Don't want to use view file for any controller action in cakePHP
on March 28, 2009
Simply write this line in the action of controller for which you don’t want to make .ctp file. $this->autoRender = false;
How Intenet can promote your business
on March 27, 2009
A web-site gives your company world-wide exposure. round the clock, 365 days a year, your site is obtainable world-wide, and can be so for a modest cost. A web-site can become a live online brochure. You can keep your web-content up-to-date and promote new products as they come obtainable. Even if you do not plan to use e commerce to sell your products …
Calculate total number of characters in a string including \n
on March 11, 2009
<?php //These will both output 2. echo strlen("\r\n"); echo mb_strlen("\r\n"); ?>

