Twitter
LinkedIn
RSS
Facebook
ClickBank1

Archive for the Cheat Sheets Category


PHP/MYSQL String Tricks

Here’s a couple things I always forget. I’m adding them here so I’ll have them for future reference.

How to “Scan and Replace” a String in MYSQL

(Note the AS400-ish wording of that title).

Big Note: Be very careful of serialized data!!!!

Thanks to http://www.mydigitallife.info/how-to-find-and-replace-text-in-mysql-database-using-sql/ for these little pieces of code.

The syntax of REPLACE is REPLACE(text_string, from_string, to_string)

Like this:

update TABLE_NAME set FIELD_NAME = replace(FIELD_NAME, ‘find this string’, ‘replace found string with this string’);

update wp_posts set post_content = replace(post_content, ‘http://domain.com/blog/’, ‘http://domain.com/’)

The above statement will replace all instances of ‘http://domain.com/blog’ to ‘http://domain.com/’ in the field of post_content of wp_posts table.

Read More...

Free Format RPG ILE Alternatives to the TIME Opcode

Time me

Here’s one of the free format BIFs I can never remember as far as syntax is concerned. Maybe if I keep it here I will be able to find it again :) . I copied some of this from http://www.bmeyers.net/faqs/frequently-asked-questions/41-free-format-alternatives-to-time (the Q&A part).

Q. In fixed format RPG IV, I used the TIME operation code to get the current date and time; but TIME is not supported by free format. You mentioned that the %DATE, %TIME, and %TIMESTAMP functions can replace TIME, but I’m not sure how to use them for this purpose.

In my programs, I create a data structure like this:

Read More...