In this topic, I will be talking about encryption and decryption using OpenSSL in PHP. I will be briefly discussing what “two way encryption” is and how to use it in your PHP application using OpenSSL encrypt and decrypt methods with a readily usable example. At the end of this page there will be a zip file where you can download and run the example.
Two way encryption (encryption and decryption) is the simplest way of securely sending some sensitve information over the Internet using a shared secret key. To make things understandble picture this scenario. A web user fills a form with some data and press the submit button. When the form is submitted, data will go from place A to place B. If we send data as it is, anyone (i.e. Spy) has access to data packets can open and see what’s inside. So, before sending data as it is we will use a convertion method (encryption) to transform human readable data (i.e. Plain text) into a human unreadable format (i.e. Cipher text). Then the receiving end will perform a data convertion exercise (decryption) to transform data back to readable format.
(Image URL :- https://commons.wikimedia.org/wiki/File:Crypto.png)
How are you doing? Seems like my fingers do not want me to stay away from Symfony2 despite the Spring Bank Holiday. 🙂
Today, I am going to talk about how to call an Oracle Function in Symfony2. A function (aka stored function) is a collection of SQL statements which is used to perform various different activities within the Database. The good thing about the function is you can write your chunks of SQL inside the function and call it using a name to initiate. I will be focusing on how to call an Oracle Function in Symfony2 and if you would like to know more about Oracle functions please click here.
First, let’s take a look at a sample function which I have created and is saved in Oracle 12c Database.
create or replace
FUNCTION testFunc123(old_bname IN VARCHAR2)
RETURN VARCHAR2 IS
IF old_bname = 'TEST' THEN
The role of the above created Oracle function is to check whether the value of ‘old_name’ is equal to ‘TEST’ or not. If it is ‘TEST’, then the function will return ‘Y’ otherwise ‘N’. So, now what we going to do is call this function inside a Symfony2 controller. This is really easy, thankfully to wonderful Doctrine2.
Update! The plugin has been approved by WordPress and it is currently available to download within the extensions directory – https://wordpress.org/plugins/aj-csv-to-datatable
Hi tech heads,
Today, I got the opportunity to create my first ever WordPress plugin. Well, this wasn’t quite planned like this but somehow I ended up creating my own WordPress plugin. Since few days, I badly wanted to show CSV data in a DataTable (yes, in Allan’s DataTables) within WordPress. So, I browsed the WordPress extensions page and found an interesting, easily configurable plugin “csv-to-sortable” which uses the JS sortable library. That is a decent plugin and does the job very well, but I wanted use DataTable instead. (Maybe I am in deep love with DataTables). I got extremely inspired by this plugin and then I decided to create a similar looking WordPress plugin so it can use DataTables to present data. I have submitted this plugin to WordPress plugins and it is currently being reviewed. However, if you want to get your hands dirty with this, before WordPress finish reviewing, then here it is.
Link to download the plugin – http://e-innoving.com/samples/wp-plugins/AJ-CSV-to-DataTable.zip
I have created a new repository in GitHub for this plugin so anyone can see what’s happening inside. Click on the link below to view the repository. Installation and usage details are also mentioned inside the GitHub page.
AJ-CSV-to-DataTable in GitHub
When you are executing a DQL there must be situation where you might need to see the parameters and its values for the underlying SQL. Usually Doctrine queries are prepared statements and you will not be able to see the values which pass through the query. Prepared statement works in the following way,
- Sending the statement,
- Sending the parameters,
- And executing the prepared statement.
(More information on prepared statements :- http://www.w3schools.com/pHp/php_mysql_prepared_statements.asp)
So, what you see when you get the SQL query is something similar to this,
SELECT * FROM some_table WHERE column1 = ? AND column2 = ?
So today, I am going to show you a workaround to get the parameters (such as column1, column2 and so on…) and most importantly get the respective values for those parameters. Continue reading
Well, today I am going to briefly discuss on couple of things which I have learned throughout my journey in Symfony 2. Well the journey is still ongoing and this brief discussion is about first couple of months, in exact terms first five months.
At very beginning, as an experienced CodeIgnitor and CakePHP developer, I found that Symfony 2 is quite confusing for me. The bundle concept started to bring some nightmares on me. The ‘bundle’ concept is a whole new experience for a developer who is sound with PHP frameworks such as CodeIgnitor and CakePHP. But today I found that, I am so lucky to get my self around with ‘bundles’, which makes developers life very straightforward and easy. I honestly believe Symfony 2, SensioLabs, Fabien did the correct thing by introducing ‘bundles’ for Symfony 2 which was not there for Symfony 1.x versions. Bundles let you organise your features, functions within your project in most efficient manner. The knowledge of arranging your projects according to functions, features within bundles will come to you once you spend sometime playing with Symfony 2. Then you come to a point, you get a feeling that how the things should get arranged in terms of Symfony 2, bundles point of view. So try your self by playing with Symfony 2, creating bundles under various vendors, etc, try your self how the bundle is created.