Archive for January, 2011

[PHP] ODBC db functions

if($type == “mysql”){
$dsn = “Driver={MySQL ODBC 3.51 Driver};Server={$host};Database={$dbname};Port={$port};”;
}
else if($type == “mssql”){
$dsn = “Driver={SQL Server};Server={$host};Database={$dbname};Port={$port};”;
}
else if($type == “oracle”){
$dsn = “Driver={Microsoft ODBC for Oracle};Server={$host};Database={$dbname};Port={$port};”;
}
else if($type == “postgresql”){
$dsn = “Driver={PostgreSQL};Server={$host};Database={$dbname};Port={$port};”;
}

$odbc_connection=odbc_connect($dsn,$user,$pw,SQL_CUR_USE_ODBC);
odbc_exec($odbc_connection, “SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED”);

$sql = ‘INSERT INTO table (col1, col2, col3…) values (?,?,?… ) ‘;

$query = odbc_prepare($odbc_connection, $sql);

$result = odbc_execute($query, $insert_col_values); //$insert_col_values is array of string for each ?,?,?… in previopus statement.

$sql = “select from table_name where condition”;

while ($row = odbc_fetch_array($rs)) {
……
……
……
}

Advertisements

Leave a Comment

[PHP] Convertin String to Time and incrementing date by one day…

Converting a date string to time object
===============================
$sUnixDateTime = strtotime($sDate)

Incrementing date by one day, result will be returned as a date object
========================================================
$sUnixDateTime = mktime(0, 0, 0, date(“m”, $sUnixDateTime), date(“d”, $sUnixDateTime)+1, date(“Y”, $sUnixDateTime));

Leave a Comment