Tuesday, December 11, 2012

0

PHP Number Format

I wanted to format a price number with two decimal places, for example 1245, here's what I did.

//code sample
number_format(1245, 2, '.', ',');

//output is 1,245.00

//First parameter (1245) is our input number
//Second paramter (2) is the number of decimal places you want
//Third parameter ('.') is the character for decimal separator
//Fourth parameter (',') is the character for thousands separator
More

Monday, December 10, 2012

0

MySQL Query With Multiple Left Join

Here is a query I used to (LEFT) join multiple tables:

SELECT 
fe.fex_uid, 
fe.ca_id,
fet.product_group_id, 
pg.name,
fet.type, 
fet.value, 
q.weight,
DATE_FORMAT( fe.timestamp,  '%Y-%m-%d' ) as fe_date

FROM 
field_executions fe
     LEFT JOIN field_execution_items fet
          ON fe.fex_uid = fet.fex_uid
     LEFT JOIN qualifiers q
          ON fet.value = q.id
     LEFT JOIN product_groups pg
          ON fet.product_group_id = pg.id

WHERE 
fe.company_id = '000002' AND
fe.ca_id = 3 AND
date_format(fe.timestamp,'%Y-%m-%d') LIKE '2012-12%'

ORDER BY 
fe.fex_uid,
fet.product_group_id
More
Powered by Blogger.