Following UNION syntax works properly in CakePHP 2.4.6 version but it doesn’t work in CakePHP 2.5.2 version:
$unionQuery = $dbo->buildStatement
‘fields’ => array( required fields),
‘table’ => $dbo->fullTableName(database_table_name),
‘alias’ => ‘customObject1’,
‘limit’ => null,
‘offset’ => null,
‘joins Read more…
Introduction: We can make our Heroku app run different type of processes by creating a Procfile in the app.
There is a specific structure and syntax that we need to follow while creating a Procfile. Following are the main points to be considered while creating a Procfile:
The Procfile must Read more…
We can create new Zoho Subscriptions via code by using PHP curl and with the help of Subscription APIs.
Below is the sample code which is required to create a subscription:
$headerArray = array(“Content-Type: application/json;charset=UTF-8”,
“Authorization: Zoho-authtoken ——–Auth Read more…
In PHP if you want to replace multiple variables of the string at one go you could use strtr() instead of using str_replace().
$vars = array(
‘##reminders##’=> ‘ ‘,
$BODY=strtr Read more…
Description: By default, CakePHP authentication is applied to all application controllers. So it does not allow users to perform any of the action without login.
Solution: Each controller has a beforeFilter method which runs when some action is called from controller. Add below lines to your method:
Public function beforeFilter Read more…
The header function in the above code does not work. But when we remove the echo from the code, it works properly.
Code after removing echo :
header(“location:https://subscriptions Read more…
Using PHPGen Eclipse plug-in one can automatically generate getter /setter methods for instance variables.
Note: This Plugins is not available in Eclipse Marketplace.
Steps For Installation:
Start Eclipse and add “Help> Install New Software” from following URL: http://loge5.de/downloads/Eclipse/:
Click Add, enter http Read more…
How to use SimpleSAMLPhp as a Service Provider for authenticating users? Some Basic steps to start using simplesamlphp.
1. Download stable version of SimpleSAMLphp from this link:
2. Go to the directory or your workspace where you want to install simpleSAMLphp, extract the zip file. Give Read more…
￼Problem: How to separate redundant piece of code from your view using cakephp 3.0.
Description: Let’s take an example. You have a list of products to display. We show products at many places such as
1. Show all products.
2. Show products of the specific category.
3. Show Read more…
Description: In one of our PHP projects, we wanted to rename all the files in zip folder and then extract the zip.
The code for this is written below :
$zip = new ZipArchive;
$res = $zip->open($sourceFolder.’\’.$file);
for ($i = 0; $i < $zip->numFiles; $i++)
$filename = $zip->getNameIndex($i);
$arr Read more…
In Moodle we had declared some new strings in lang file of a plugin like this:
$string[‘LIBRARY_NAME’] = ‘E-Lab’;
$string[‘BOOK_READ_SUCCESS’]=’Congratulations on reading the book’;
We wanted to use it in view.php file of the plugin like this:
$result=Get_String(‘BOOK_READ_SUCCESS’, ‘plugin name’);
But the output was Read more…
Using PDFtk we can merge multiple files into a single file using a command like this:
Example : pdftk file1 file2 output file3.
Sample code to accomplish the same using PHP is given below:
$outputPDFName = “mergeResult.pdf”;
$multiplePDFs = $multiplePDFs Read more…
In one of our Moodle projects, we modified a plugin’s code to add extra functionality to plugin. The modification in plugin’s code was not reflected and Moodle showed the older version of plugin.
To solve this problem, we upgraded the Moodle database and changes in plugin’s code Read more…
Problem: Undo deleted file in Eclipse
Solution: We were working on a project in Eclipse. Accidentally one of the PHP files got deleted in which code was written. Eclipse does not use the Linux ‘Trash’ but keeps local history from where we were able to recover the file.
Follow these Read more…
We get this request from a lot of clients in US insurance industry who want to generate ACORD forms automatically, means they want data of corresponding insurance Policy and other objects filled automatically in the editable ACORD PDF. Most of the clients have their data in a CRM system like Read more…
A lot of Zoho users want to extend the capability that Zoho CRM provides out of the box. For example, one of our clients wanted to build a custom Quote Generator. They initially wanted to get the customization done to default Zoho CRM Quote form but their requirements were not Read more…
To convert date from one format to another we need to specify to php interpreter the format of our current value. See code below:
In statement below, we are providing date and format to DateTime::createFromFormat function so that function could know day, month and year values separately
$date = DateTime Read more…
strpos($wholeText, $findText) in PHP returns position from which the $findText value starts if it is present in $wholeText. If it is not found then this function returns false. Fun starts when text is found at the very beginning (at position 0, as 0 is equivalent to false in PHP Read more…
Solution: In following example we have filtered files which are modified on current date (today’s date):
$files = scandir($source);
$archiveFiles = array();
foreach($files as $file)
$lastModified = date(‘d/m/y’,filemtime($source . ‘/’ .$file));
array_push Read more…
The Isset () Function:
The isset () function is used when we have to check whether a value in the variable is set or not. It returns false when variable contains null values.
For Example, values are stored in a session so that it can have access to another web Read more…