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 ".
    ";";

Link to comment
Share on other sites

$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.

Link to comment
Share on other sites

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!

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.