bulrush Posted September 17, 2010 Share Posted September 17, 2010 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 ". ";"; Quote Link to comment https://forums.phpfreaks.com/topic/213677-windows-util-sql-to-php-string-assignment/ Share on other sites More sharing options...
mikosiko Posted September 17, 2010 Share Posted September 17, 2010 and why you need to do that with a "tool" ? Quote Link to comment https://forums.phpfreaks.com/topic/213677-windows-util-sql-to-php-string-assignment/#findComment-1112180 Share on other sites More sharing options...
PFMaBiSmAd Posted September 17, 2010 Share Posted September 17, 2010 $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. Quote Link to comment https://forums.phpfreaks.com/topic/213677-windows-util-sql-to-php-string-assignment/#findComment-1112187 Share on other sites More sharing options...
bulrush Posted September 17, 2010 Author Share Posted September 17, 2010 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! Quote Link to comment https://forums.phpfreaks.com/topic/213677-windows-util-sql-to-php-string-assignment/#findComment-1112188 Share on other sites More sharing options...
mikosiko Posted September 17, 2010 Share Posted September 17, 2010 and for other circumstances you can use heredoc or nowdoc syntax when neccesary. http://php.net/manual/en/language.types.string.php Quote Link to comment https://forums.phpfreaks.com/topic/213677-windows-util-sql-to-php-string-assignment/#findComment-1112192 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.