Narendra
  • Home
  • About
KEEP IN TOUCH

Caching problem with models in CakePHP

Sep24
2010
3 Comments Written by Narendra Vaghela

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

Posted in CakePHP - Tagged CakePHP, models

MySQL : Get next auto increment value in a MySQL table

Sep11
2010
6 Comments Written by Narendra Vaghela

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

Posted in MySQL - Tagged MySQL

Upgrade your WordPress site or blog for free..

Sep07
2010
Leave a Comment Written by Narendra Vaghela

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….

Posted in WordPress - Tagged wordpress

Integrate WordPress into CakePHP

Aug29
2010
3 Comments Written by Narendra Vaghela

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

Posted in CakePHP - Tagged CakePHP

How to abort an ajax request using jQuery

Jul31
2010
5 Comments Written by Narendra Vaghela

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();

Posted in jQuery - Tagged ajax, jQuery

Read CSV file in CakePHP

Jun19
2010
7 Comments Written by Narendra Vaghela

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

Posted in CakePHP - Tagged CakePHP, CSV

Bind event using jQuery

Jun18
2010
Leave a Comment Written by Narendra Vaghela

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

Posted in jQuery - Tagged bind event, jQuery

Check element is visible or hidden using jQuery

Jun18
2010
3 Comments Written by Narendra Vaghela

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

Posted in jQuery - Tagged hidden, jQuery, visible

set/get attribute of element using jQuery

Jun04
2010
Leave a Comment Written by Narendra Vaghela

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');

Posted in jQuery - Tagged attribute, jQuery

set/get attribute of element using Javascript

Jun04
2010
4 Comments Written by Narendra Vaghela

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');

Posted in Javascript - Tagged getAttribute, Javascript, setAttribute
« Older Entries

Categories

  • CakePHP
  • Javascript
  • jQuery
  • MySQL
  • WordPress

Recent Posts

  • Caching problem with models in CakePHP
  • MySQL : Get next auto increment value in a MySQL table
  • Upgrade your WordPress site or blog for free..
  • Integrate WordPress into CakePHP
  • How to abort an ajax request using jQuery

Tags

ajax attribute bind event CakePHP component CSV getAttribute hidden iframe Javascript jQuery models MySQL recaptcha row selectbox setAttribute table visible wordpress

Useful Links

  • MyCakePHP
  • PacificWithin

EvoLve theme by Theme4Press  •  Powered by WordPress Narendra