Jump to content
mongoose00318

Format all dates in an array returned from PDO

Recommended Posts

Is their a way to format lr.submit_time in every record that is returned in the $results array without doing like a for/foreach loop? Like array_walk() or something similar?

$query = "
				SELECT
					lr.*,
					l.make,
					l.model,
					l.part_number,
					l.description,
					pd.job_number,
					pd.line_item,
					pd.enterprise,
					pd.description,
					pd.qty AS order_qty,
					log.name AS user_full_name
				FROM
					leds_requests lr
				LEFT JOIN
					leds l
				ON
					l.id = lr.product_id
				LEFT JOIN
					production_data pd
				ON
					pd.id = lr.order_id
				LEFT JOIN
					login log
				ON
					log.user_id = lr.user_id
				WHERE
					lr.id IN(
					SELECT
						MAX(id)
					FROM
						leds_requests
					WHERE
						status_id = 0
					GROUP BY
						order_id,
						product_id
				) AND lr.id NOT IN(
					SELECT
						id
					FROM
						leds_requests
					WHERE
						lr.id = id AND status_id IN(1, 2, 3, 4)
				)
				GROUP BY
					order_id,
					product_id,
					job_number
	";
	$statement = $pdo->prepare($query);
	$statement->execute();
	$results = $statement->fetchAll();
	
	echo json_encode($results);

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.