This ant task can be used to crudely change all of the mysql_xxx calls to mysqli.
- Code: Select all
<target name="convert-mysqli">
<replace token="mysql_query" value="mysqli_query">
<fileset dir="." includes="**/*.php"/>
</replace>
<replace token="mysql_fetch_row" value="mysqli_fetch_row">
<fileset dir="." includes="**/*.php"/>
</replace>
<replace token="mysql_fetch_assoc" value="mysqli_fetch_assoc">
<fileset dir="." includes="**/*.php"/>
</replace>
<replace token="mysql_fetch_object" value="mysqli_fetch_object">
<fileset dir="." includes="**/*.php"/>
</replace>
<replace token="mysql_affected_rows" value="mysqli_affected_rows">
<fileset dir="." includes="**/*.php"/>
</replace>
<replace token="mysql_connect" value="mysqli_connect">
<fileset dir="." includes="**/*.php"/>
</replace>
<replace token="mysql_free_result" value="mysqli_free_result">
<fileset dir="." includes="**/*.php"/>
</replace>
<replace token="mysql_escape_string" value="mysqli_real_escape_string">
<fileset dir="." includes="**/*.php"/>
</replace>
<replace token="mysql_real_escape_string" value="mysqli_real_escape_string">
<fileset dir="." includes="**/*.php"/>
</replace>
<replace token="mysql_error" value="mysqli_error">
<fileset dir="." includes="**/*.php"/>
</replace>
<replace token="mysql_errno" value="mysqli_errno">
<fileset dir="." includes="**/*.php"/>
</replace>
<replace token="mysql_fetch_array" value="mysqli_fetch_array">
<fileset dir="." includes="**/*.php"/>
</replace>
<replace token="mysql_fetch_lengths" value="mysqli_fetch_lengths">
<fileset dir="." includes="**/*.php"/>
</replace>
<replace token="mysql_num_rows" value="mysqli_num_rows">
<fileset dir="." includes="**/*.php"/>
</replace>
<replace token="mysql_pconnect" value="mysqli_pconnect">
<fileset dir="." includes="**/*.php"/>
</replace>
<replace token="mysql_insert_id" value="mysqli_insert_id">
<fileset dir="." includes="**/*.php"/>
</replace>
<replace token="mysql_select_db" value="mysqli_select_db">
<fileset dir="." includes="**/*.php"/>
</replace>
<replace token="mysql_data_seek" value="mysqli_data_seek">
<fileset dir="." includes="**/*.php"/>
</replace>
<replace token="mysql_client_encoding" value="mysqli_character_set_name">
<fileset dir="." includes="**/*.php"/>
</replace>
<replace token="mysql_close" value="mysqli_close">
<fileset dir="." includes="**/*.php"/>
</replace>
</target>
Of course, this (or something similar) would need to be run on all modules and application logic as well to remove all mysql_xxx references from the code.
For the actual solution, I will probably factor the calls out into a wrapper library to make it easier to, possibly, have to change the library again in the future.
-Steve