Created
August 20, 2016 11:12
-
-
Save aedorado/4b0651c6a463bcd9b11cdd9a570725e2 to your computer and use it in GitHub Desktop.
Generate bindParam statements for given sql query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
s = "SELECT * FROM course_strucure WHERE program_id = :program_id AND year_of_joining = :year_of_joining AND sem_code_of_joining = :sem_code_of_joining" | |
s = sys.argv[1] | |
print ( "$sql = \"" + s + "\";" ) | |
s = s.split() | |
s = [x for x in s if x[0]==':'] | |
print ( "$stmt = $conn->prepare($sql);" ) | |
for x in s: | |
print ( "$stmt->bindParam('" + x + "', $" + x[1:] + ");") | |
print ( "$stmt->execute();" ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment