Jump to content

Windows util: SQL to PHP string assignment


bulrush

Recommended Posts

I'm looking for a Windows utility to convert this:

 

SELECT brands.brand, brands.partid, bullets.bullid, bullets.bullettext, bullets.buorder, 
count(bullets.partid) as bucnt, bullets.partid as bupartid FROM brands 
JOIN bullets ON (brands.partid=bullets.partid) 
WHERE (brands.partid=".$partid.") AND (brands.brand<>'".$brand."') 
GROUP BY brand HAVING bucnt > 0 
ORDER BY brand, partid;

to this:

    $query2="SELECT brands.brand, brands.partid, bullets.bullid, ".
    "bullets.bullettext, bullets.buorder, ".
    "count(bullets.partid) as bucnt, bullets.partid as bupartid ".
    "FROM brands ".
    "JOIN bullets ON (brands.partid=bullets.partid) ".
    "WHERE (brands.partid=".$partid.") ".
    "AND (brands.brand<>'".$brand."') ".
    "GROUP BY brand ".
    "HAVING bucnt > 0 ".
    "ORDER BY brand, partid ".
    ";";

$query2 = "SELECT brands.brand, brands.partid, bullets.bullid, bullets.bullettext, bullets.buorder, 
count(bullets.partid) as bucnt, bullets.partid as bupartid FROM brands 
JOIN bullets ON (brands.partid=bullets.partid) 
WHERE (brands.partid=".$partid.") AND (brands.brand<>'".$brand."') 
GROUP BY brand HAVING bucnt > 0 
ORDER BY brand, partid";

 

There's no need for all the quotes and concatenation nonsense. You can write a multi-line query.

Because with a tool, it will save me 2 minutes of typing each time I do this, and I do this a lot while developing. So I am saving 20 minutes, then 200 minutes, etc. The time saved adds up. I made my own tool to do this for MS Access but I don't have it anymore.

 

EDIT: I did not realize I could do a multi-line query assigned to a PHP variable. Thanks!

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.