Migrating a PostgreSQL Database to SQL Anywhere 12 - Sybase
Migrating a PostgreSQL Database to SQL Anywhere 12 - Sybase
Migrating a PostgreSQL Database to SQL Anywhere 12 - Sybase
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
<strong>Postgre<strong>SQL</strong></strong>_fetch_row odbc_fetch_row sqlanywhere_fetch_row<br />
<strong>Postgre<strong>SQL</strong></strong>_insert_id<br />
See “<strong>Postgre<strong>SQL</strong></strong>_insert_id”<br />
note.<br />
sasql_insert_id<br />
<strong>Postgre<strong>SQL</strong></strong>_num_fields odbc_num_fields sqlanywhere_num_fields<br />
<strong>Postgre<strong>SQL</strong></strong>_num_rows odbc_num_rows sqlanywhere_num_rows<br />
<strong>Postgre<strong>SQL</strong></strong>_query odbc_exec sqlanywhere_query<br />
<strong>Postgre<strong>SQL</strong></strong>_select_db none none<br />
Notes:<br />
<strong>Postgre<strong>SQL</strong></strong>_escape_string: The ODBC php driver does not provide a way <strong>to</strong> escape a <strong>SQL</strong> string. However,<br />
this can be easily done by replacing each single quote with two single quotes.<br />
<strong>Postgre<strong>SQL</strong></strong>_insert_id: This function returns the last inserted ID of an au<strong>to</strong>increment column. The same<br />
result can be obtained by issuing the following <strong>SQL</strong> statement:<br />
SELECT @@identity<br />
PHP migration notes<br />
These are subtle differences in the way <strong>SQL</strong> strings are treated by the various database vendors. For example,<br />
timestamps in <strong>Postgre<strong>SQL</strong></strong> have the format YYYY-MM-DD hh:mm:ss, while <strong>SQL</strong> <strong>Anywhere</strong> supports timestamps<br />
with fractions of a second. Extra work must be done <strong>to</strong> remove the fractional second portion of the <strong>SQL</strong><br />
<strong>Anywhere</strong> timestamp for sue with str<strong>to</strong>time() for example.<br />
<strong>SQL</strong> <strong>Anywhere</strong> via ODBC also provides support for transactions and prepared statements. The odbc_commit<br />
and odbc_rollback functions terminate a transaction as you would expect. One point <strong>to</strong> notice is that PHP<br />
defaults <strong>to</strong> au<strong>to</strong>commit, meaning every statement is committed as soon as it is successfully executed. The<br />
odbc_au<strong>to</strong>commit function is used <strong>to</strong> set the au<strong>to</strong>commit behavior <strong>to</strong> enable the use of large transactions.<br />
Prepared statements are useful if the same queries, possibly with different parameters, are <strong>to</strong> be executed<br />
many times. This can help create efficiency as each dynamic <strong>SQL</strong> statement is built within the engine once<br />
only. The odbc_prepare and odbc_execute functions are used <strong>to</strong> execute prepared statements.<br />
14 <strong>Migrating</strong> a <strong>Postgre<strong>SQL</strong></strong> <strong>Database</strong> <strong>to</strong> <strong>SQL</strong> <strong>Anywhere</strong> <strong>12</strong><br />
December 2011