Codeigniter how to display the query that was executed?

Filed Under (Others) by admin on 23-01-2012

To display the executed query using the codeigniter database class
insert the line of code below

echo $this->db->last_query();

$this->db->last_query(); //returns the last executed query
————————————————————————————————-
So if your code is like this

$this->db->select('*');
$this->db->from('sales');
$query = $this->db->get();
echo $this->db->last_query();

// Adding echo $this->db->last_query(); will output the query on the page like this

// SELECT * FROM sales;

Find files that are created more than 7 days and delete them using bash

Filed Under (linux) by admin on 18-01-2012

Here we will use the find -mtime and xargs commands

Complete script:

find '/home/user/data/' -name '*.txt' -mtime +7 | xargs rm

Explanation:
find -mtime displays files made based on given number of days

find '/home/user/data/' -name '*.txt' -mtime +7

xargs captures the result of a previous command and pass it as an argument for another function

find '/home/user/data/' -name '*.txt' -mtime +7 | xargs rm

The result of the find command is passed to another function rm which then removes the files

Create a database backup using mysqldump and gzip

Filed Under (Others) by admin on 18-01-2012

mysqldump -u username -p Password database_name | gzip > database_backup.sql.gz

Create a zip file and append the date on the filename in linux

Filed Under (Others) by admin on 29-12-2011

When we backup we want to add a date on the filename to know when the file was created

Try this line

tar -zcvf database_backup_$(date +%m-%d-%Y).tar.gz /DB/data

jquery perfomance tips

Filed Under (jquery) by admin on 14-12-2011

I have just stumbled on this performance tip so I tried and tested it, so far the results were good there are some speed improvement on my jquery codes.

Optimize selectors for Sizzle’s ‘right to left’ model
As of version 1.3, jQuery has been using the Sizzle Javascript Selector Library which works a bit differently from the selector engine used in the past. Namely it uses a ‘right to left’ model rather than a ‘left to right’. Make sure that your right-most selector is really specific and any selectors on the left are more broad:

var linkContacts = $(‘.contact-links div.side-wrapper’);

instead of:

var linkContacts = $(‘a.contact-links .side-wrapper’);

More tips from this website
http://dumitruglavan.com/jquery-performance-tips-cheat-sheet/

MySQL Duplicate entry for key PRIMARY on Auto_Increment

Filed Under (Others, mysql) by admin on 14-12-2011

Tagged Under :

Example errors:

“Duplicate entry ’123711155′ for key ‘PRIMARY’” or “Duplicate entry ’14676163′ for key ’1′”

Most likely this happens for tables with more than 5 million records

THE FIX

The fix is to use repair table

REPAIR TABLE <TABLE_NAME>;

Note: Sometimes the duplicate error is also caused by your field type having the maximum value already, for example in tinyint which has the maximum value of 127 so it better to use bigint for your auto ids, if this is not the case you can try the solution above.

Java find the size of an array

Filed Under (java) by admin on 15-11-2011

Use Java Array Length.

Example:

String months[] = {"Jan", "Feb", "Mar", "Apr", "May",
 "Jun", "July", "Aug", "Sep", "Oct", "Nov", "Dec"};

System.out.println(months.length);

Value of months.length is equal to 12

Ubuntu certified laptops and hardware for 10.10 and 11.04

Filed Under (linux) by admin on 14-11-2011

Tagged Under :

Check if your laptop is fully compatible with ubuntu

http://www.ubuntu.com/certification/

Run a titanium project using the command line

Filed Under (Others) by admin on 09-11-2011

1. Go to your titanium project folder

then

2. Run this command

python titanium.py run --platform=android --android=/path/to/android-sdk

3. It’s Done

Note: Your titanium project folder should have the ff:

build build.log LICENSE manifest README Resources tiapp.xml

svn connection refused

Filed Under (Others) by admin on 29-08-2011

Most likely this is caused by a closed svn port on your svn server

Login to your svn server then do the following

1. Check first if svn is running
ps aux | grep svnserve

2. If it is not running restart the svn service
svnserve -d -r path_of_svn

ads
ads

Jobs at Lexmark Cebu

Software Tools Developer 5 Dec 2008, 1:11 pm

Software Tools Developer

Source: Jobs at Lexmark Jobs at Lexmark |

Company Nurse 5 Dec 2008, 1:11 pm

Company Nurse

Source: Jobs at Lexmark Jobs at Lexmark |

Industrial Designer 5 Dec 2008, 1:11 pm

Industrial Designer

Source: Jobs at Lexmark Jobs at Lexmark |

Data Owner 5 Dec 2008, 1:11 pm

Data Owner

Source: Jobs at Lexmark Jobs at Lexmark |

Firmware Product Systems Engineer (FPSE) 5 Dec 2008, 1:11 pm

Firmware Product Systems Engineer (FPSE)

Source: Jobs at Lexmark Jobs at Lexmark |

Talent Management Specialist 5 Dec 2008, 1:11 pm

Talent Management Specialist

Source: Jobs at Lexmark Jobs at Lexmark |

Business Control Analyst (Auditor) 5 Dec 2008, 1:11 pm

Business Control Analyst (Auditor)

Source: Jobs at Lexmark Jobs at Lexmark |

SAP System Analyst 5 Dec 2008, 1:11 pm

SAP System Analyst

Source: Jobs at Lexmark Jobs at Lexmark |

Firmware Development Engineers 5 Dec 2008, 1:11 pm

Firmware Development Engineers

Source: Jobs at Lexmark Jobs at Lexmark |

HR Officer (Shared Services) 5 Dec 2008, 1:11 pm

HR Officer (Shared Services)

Source: Jobs at Lexmark Jobs at Lexmark |

Technical Writers 5 Dec 2008, 1:11 pm

Technical Writers

Source: Jobs at Lexmark Jobs at Lexmark |

Spanish-speaking Customer Service Representative 5 Dec 2008, 1:11 pm

Spanish-speaking Customer Service Representative

Source: Jobs at Lexmark Jobs at Lexmark |

Technical Illustrator 5 Dec 2008, 1:11 pm

Technical Illustrator

Source: Jobs at Lexmark Jobs at Lexmark |

Recruitment Assistant 5 Dec 2008, 1:11 pm

Recruitment Assistant

Source: Jobs at Lexmark Jobs at Lexmark |

Team Lead 5 Dec 2008, 1:11 pm

Team Lead

Source: Jobs at Lexmark Jobs at Lexmark |

Technical Support Representative 5 Dec 2008, 1:11 pm

Technical Support Representative

Source: Jobs at Lexmark Jobs at Lexmark |

Technical Trainer 5 Dec 2008, 1:11 pm

Technical Trainer

Source: Jobs at Lexmark Jobs at Lexmark |

Software Build and Library Administrator 5 Dec 2008, 1:11 pm

Software Build and Library Administrator

Source: Jobs at Lexmark Jobs at Lexmark |

Business Database Administrator 5 Dec 2008, 1:11 pm

Business Database Administrator

Source: Jobs at Lexmark Jobs at Lexmark |

EDI - Support Analyst 5 Dec 2008, 1:11 pm

EDI - Support Analyst

Source: Jobs at Lexmark Jobs at Lexmark |