Before a few days, I was working on a project in CakePHP. I made some model related changes, like changed the relationship of models and added new fields to table in database. After uploading the code to live server, when I checked the site, no difference was seen as compared to earlier version of site. I wondered what had happened. Where have all the changes gone or why no change has been applied even though I changed the code in models? Everything was working fine, except that the changes
MySQL : Get next auto increment value in a MySQL table
Recently, I needed to get the auto increment value for the next inserted row in a MySQL table. As the first solution, I was thinking to get maximum of ‘id’ field and then increment it for next inserted record like, $query = mysql_query(SELECT MAX(id) as max_id FROM tablename); $row = mysql_fetch_array($query); $next_id = $row[‘max_id’] + 1; But it is not a right way to do this because auto increment values use unique ids. By doing some research, I found a solution for this
Upgrade your WordPress site or blog for free..
Yes, you heard that right… got a WordPress site or blog ? if yes, MULTIDOTS offers free upgradation to latest version of WordPress. For more information visit : http://www.guptaanil.com/free-wordpress-upgrade-at-multidots/ Its a campaign cum activity started by WordPress group at MULTIDOTS. So hurry up and avail yourself of new features offered by latest version of wp….
Integrate WordPress into CakePHP
Sometimes ago I was working on a project based on CakePHP framework. And requirement was to integrate a blogging application into CakePHP. Well, everyone knows that Wordpress is the best Blog framework ever made. So I decided to integrate Wordpress into CakePHP. Now, the first thing is if you want to integrate Wordpress in CakePHP, you have to put that in app/webroot folder. So, put Wordpress folder into app/webroot of your CakePHP. But cake doesn’t keep the address to
How to abort an ajax request using jQuery
The $.ajax method returns the xhr object, and you can call the abort method of it. Every time you create an ajax request you could use a variable to store it: var x = $.ajax({ type: 'POST', url: 'someurl', success: function(result){} }); Then you can abort the request: x.abort();
Read CSV file in CakePHP
First download class file for reading CSV file from here . Now copy the main class file to your app/vendors/ and name it parsecsv.php. Now in your controller’s action where you want to read CSV data, import that file using App::import function, function readCSV() { App::import("Vendor","parsecsv"); } Then create object of the class, function readCSV() { App::import("Vendor","parsecsv"); $csv = new parseCSV(); } To read a CSV file, you have to use the following
Bind event using jQuery
To bind event to an element using jQuery is very easy task. See the following examples, $('#foo').bind('click', function() { // other stuff }); You can also call external function like below, function clickEvent() { alert('Clicked'); } $('#foo').bind('click', clickEvent); Another way to bind event, $('#foo').click(clickEvent); or you can write inline function like below, $('#foo').click(function(){ alert('Clicked'); }); Above examples are for “click” event, but you can use
Check element is visible or hidden using jQuery
jQuery makes it easy to check if an element is visible or hidden with the is() function. Check if an element is visible In the following HTML code the div is hidden <div id="foo" style="display:none"></div> Now to check if it is visible or not, use the is() function with “:visible” parameter, if( $('#foo').is(':visible') ) { // div is visible, do something } else { // div is not visible so do something else } Check if an element is hidden This is same process as
set/get attribute of element using jQuery
To set attribute of element, $('#element_id').attr('attr_name','attr_value'); $('#my_div').attr('class','custom_div'); //using id $('div.my_class').attr('id','my_div'); //using class name To get attribute of element, var attr = $('#id or .class').attr('attr_name');
set/get attribute of element using Javascript
To set attribute of an element, <p id="myID" attr="attribute value"></p> <script> var pTag1 = document.getElementById('myID'); pTag1.setAttribute('attr', 'new attribute value'); document.write(pTag1.getAttribute('attr')); </script> To get attribute value, var attr_val = document.getElementById('element_id').getAttribute('attribute_name'); var div_id = document.getElementById('my_div').getAttribute('id');