I am using the ODBC extension in PHP to connect to an SQL 2000 server. Here is what I am up against:
- I can execute queries with
odbc_exec()OR - I can execute queries with
odbc_execute()
In my opinion, the differences between these two query executing methods are nearly as different as night and day:
odbc_exec()will execute a non SQL-safe query and return the results from the queryodbc_execute()is used in conjunction withodbc_prepare()to execute an SQL safe query on the database. However,odbc_execute()can only ever return a boolean, and therefore cannot be used to return the results from aSELECTstatement, or to check how many rows were updated from anUPDATEorDELETEstatement
Is this really the way this all works, or is there some way to escape values for use in odbc_exec() or to get the results back from odbc_execute()?
The PHP documentation doesn’t seem to over any solutions for the above dilemma.
Thank you for your time.
The resource for the query you’re running is returned by the odbc_prepare function, not odbc_execute.
These two blocks of code do the same thing: