How to access Camera and upload the image/video to server?
We can achieve above requirements easily by using HTML Media Capture :
<form action=”upload.php” method=”post” enctype=”multipart/form-data”>
Capture Image: <input type=”file” name=”uploadedfile” accept=”image/*” capture=”camera”>
<input type Read more…
In moodle we can create scheduled tasks which will run after a defined interval. We also have cron jobs in moodle but they usually run after every minute so if we need to run a task after a particular time we need to create a scheduled task for this.
An Read more…
Some important settings that can help you while working with CakePHP 3 or 2.
1. How to set Homepage for your website in CakePHP 3?
Go to the root directory of your project. You will see config folder there. Inside Config
folder, open routes.php file. Add below the line Read more…
Problem: How to get list of all the Salesforce sobjects in php. Also get fields of each sobject.
Solution: First we need to install Salesforce php toolkit for this. Once you have it then this is the sample code:
require_once(SFDCPHPtoolkit / soapclient / SforcePartnerClient.php ‘);
$mySforceConnection = new Read more…
How to view List of constraints of tables of Database in phpMyAdmin
There are various ways by which we can view the list of constraints applied to tables of given database in PhpMyadmin. Let’s see few methods here:
Suppose we have a database named CollegeDb Read more…
Column 3 layout in Moodle is basically dividing the screen into 3 parts .
user setting options Layout (pre )
content layout (region)
editing layout (post)
user setting options Layout (pre): In column3 layout pre region is the first column. This column is at the left of the content. This Read more…
cipherSeed in CakePHP
cipherSeed is used in Security::cipher() function to seed rand(). Seed means to give the initial value to rand() function to start and based on that the future values by rand() function are generated. In php, before 4.2.0 version, Random Number Read more…
Heroku throwing ERROR: “The datasource configuration “default” was not found in database.php” with database configuration already present for cakephp app.
In one of our cakephp projects hosted on Heroku we used PostgreSql database. For configuring the database to connect to app code we renamed the database.php.default file Read more…
CakePHP Security Component is very useful and provides an easy way to enable very tight security in our application:
1. It can restrict which HTTP methods our application accepts.
2. It provides Form Tampering Protection.
3. It can force to require that SSL must be used.
4. It Read more…
In Totara how to add custom HTML elements (checkboxes, input boxes etc) and then access the value selected by user on server side:
1. Adding custom elements.
2. Accessing values of custom elements.
Each problem is discussed below: Overview:
In Totara, for blocks, we have some Read more…
In our Shopify store we have an order creation webhook that points to a cakephp action URL. The action that webhook points to fetches the order data and then saves this to the database.
The problem that we were facing with this webhook was that it was getting invoked multiple Read more…
In wordpress we can get title from post title and description from post content area dynamically:
$id = get_the_ID(); //get the post id.
$title = get_the_title($id); //get title from the post.
$content = get_post_field(‘post_content’, $id); // Get all content from post content area.
$trimmed_content = wp_trim_words( $content, 20, ‘….’ ); // This function trims Read more…
While fetching data from database, in SQL query I had ‘order by’ clause but the results were not sorted when the data was in alphanumeric form. The reason for this is that SQL sorts character by character from left to right. So it places c10 before c2 as 1< Read more…
Let us take an example:
We have table employees with following fields:
id int primary key,
We have following records in the table:
(1, isha, amr);
(2, Hamlet’s, ghy);
(3, éhjj, amr);
2nd and 3rd records have special characters in their Read more…
We have two tables say table1 and table 2. In table 1, there is a field named Id and this field is set as primary key in table 1. We want to use it as foreign key in table 2.
Fields in both the tables:
Id Read more…
European characters like è é å ñ ü ,à, è, ì, ò, ù – À, È, Ì, Ò, Ù, ™, © ,• , ∑, α, β, «, » do not get inserted correctly in MySQL by default. To fix it, we need to change the character set (fixed collection of symbols) and collation (set of rules that determine how data is sorted and compared).
To insert and retrieve european characters change character set to utf Read more…
Suppose we want to have columns created_date and last_modified_time with default timestamp in any table in MySQL/Phpmyadmin.
Let us take an example of Students table.
Create table Students using following query :
CREATE TABLE students(
id INT AUTO_INCREMENT PRIMARY KEY ,
first_name varchar(20) NOT NULL,
last_name varchar(20) NOT NULL Read more…
To implement Internationalization, CakePHP will pick all your strings which start with “__(“ double underscore ) and generate a default file for you.
For Example: one of the strings defined in our project is as below:
echo __ ( ‘ Gift Cards Not available’ );
Replace all your normal string with (__ Read more…
We can’t use special characters like >,<,”,’ etc directly in code because browser mixes these characters with HTML tags and gets confused. So we can use HTML entities if we want to use special characters in our code.
Below are some common entities which we can use Read more…
var test = [“test1”, “test2”, “test3”];
Now create a hidden variable in HTML. This variable will Read more…