A web developer's blog. PHP, MySQL, CakePHP, Zend Framework, Wordpress, Code Igniter, Django, Python, CSS, Javascript, jQuery, Knockout.js, and other web development topics.

Tag Archives: MySQL

How to do a Select statement inside the main select statement in MySQL

A little bit slow but it gets the job done. I used this to generate a report to get the total open_amount for customers. SELECT s.parent_no, s.parent_name, t.parent_no, t.col_manager, t.invoice_date, t.due_date, t.over_7_date, t.over_7_by_eom, t.open_amount,   (SELECT SUM(t2.open_amount) FROM transactions t2 … Continue reading

Posted in General | Tagged | Leave a comment

How to filter database inserts – HTML, Usernames, etc. in Zend Framwork

I woke up today thinking about how to handle strings when inserting to MySQL. What if the string I am trying to save into the database contains HTML characters? Let’s say you are using FCKEditor, how would you “generally” handle … Continue reading

Posted in General | Tagged , , | 6 Comments

Update rows in Table A from values of Table B in MySQL

Sometimes, we need to update values of tables from the values from another table. Here is an example: UPDATE `transactions` t , `tran_daily` daily SET t.col_manager = daily.Col_manager, t.invoice_date = daily.Invoice_date, t.due_date = daily.Due_date, t.po_no = daily.Po_no, t.remark = daily.Remark, … Continue reading

Posted in General | Tagged | Leave a comment

What is the safest way to do database queries in Zend Framework?

I have no idea. You tell me. All I do is this: $sql = "SELECT * FROM Table1 WHERE id=’".$target_id."’"; /*That is $target_id inside single-quotes in the SQL Query.*/ Please share your thoughts below.

Posted in General | Tagged , | 9 Comments

LAMP’s success is spelling its own doom?

Here is a very interesting post regarding LAMP (Linux, Apache, MySQL and PHP). I agree with the post all the way. So whats the problem here? Well I think one of the key issues is that LAMP focus on solving … Continue reading

Posted in General | Tagged , , , | Leave a comment

Convert Database to UTF-8

I deal with a lot of database dumps. So this post is a must for me. We seriously see a ton of customers coming in with the type of databases that are a nightmare to move over. When you’re dealing … Continue reading

Posted in General | Tagged | Leave a comment

Don’t use addslashes for database escapes

From jansch.nl: This is not the best way to escape data. The most important reason is security. addslashes can lure you into a false sense of security. As Chris Shiflett points out, there are situations that addslashes doesn’t escape. Use … Continue reading

Posted in General | Tagged , , | Leave a comment

PHP 5: MySQL Singleton Example

What is a Singleton? In software engineering, the singleton pattern is a design pattern that is used to restrict instantiation of a class to one object. This is useful when exactly one object is needed to coordinate actions across the … Continue reading

Posted in General | Tagged , , , | Leave a comment

MyLyricsFinder.com: Caching MySQL Queries

It is Saturday night and it is raining like it hasn’t rained in weeks. So I decided to spend the night to work on my pet project: MyLyricsFinder.com. It uses the Zend Framework. The latest addition tonight is Zend_Cache. I … Continue reading

Posted in General | Tagged , , , , | Leave a comment

New XAMMP for Windows, Linux and Mac OS X

Last October 8, Apache Friends released new versions of XAMMP for Windows, Linux and Mac OS X. I use XAMMP on Windows, but for Mac OS X, I use MAMP – the Mac OS X release of XAMMP is still … Continue reading

Posted in General | Tagged , , , , | Leave a comment