... I've fixed that now.
$ADODB_SESS_DEBUG,
$ADODB_SESS_INSERT;
- /* $ADODB_SESS_DEBUG = true; */
+ //$ADODB_SESS_DEBUG = true;
/* SET THE FOLLOWING PARAMETERS */
if (empty($ADODB_SESSION_DRIVER)) {
$ADODB_SESS_LIFE = get_cfg_var('session.gc_maxlifetime');
if ($ADODB_SESS_LIFE <= 1) {
- /* bug in PHP 4.0.3 pl 1 -- how about other versions? */
- /* print "<h3>Session Error: PHP.INI setting <i>session.gc_maxlifetime</i>not set: $ADODB_SESS_LIFE</h3>"; */
+ // bug in PHP 4.0.3 pl 1 -- how about other versions?
+ //print "<h3>Session Error: PHP.INI setting <i>session.gc_maxlifetime</i>not set: $ADODB_SESS_LIFE</h3>";
$ADODB_SESS_LIFE=1440;
}
$ADODB_SESS_INSERT = true;
$v = '';
} else {
- /* Decrypt session data */
+ // Decrypt session data
$v = rawurldecode($Crypt->Decrypt(reset($rs->fields), ADODB_Session_Key()));
}
$rs->Close();
$expiry = time() + $ADODB_SESS_LIFE;
- /* encrypt session data.. */
+ // encrypt session data..
$val = $Crypt->Encrypt(rawurlencode($val), ADODB_Session_Key());
$qry = "UPDATE $ADODB_SESSION_TBL SET expiry=$expiry,data='$val' WHERE sesskey='$key'";
$rs = $ADODB_SESS_CONN->Execute($qry);
if ($rs) $rs->Close();
else print '<p>Session Insert: '.$ADODB_SESS_CONN->ErrorMsg().'</p>';
}
- /* bug in access driver (could be odbc?) means that info is not commited */
- /* properly unless select statement executed in Win2000 */
+ // bug in access driver (could be odbc?) means that info is not commited
+ // properly unless select statement executed in Win2000
if ($ADODB_SESS_CONN->databaseType == 'access') $rs = $ADODB_SESS_CONN->Execute("select sesskey from $ADODB_SESSION_TBL WHERE sesskey='$key'");
return isset($rs);
$rs = $ADODB_SESS_CONN->Execute($qry);
if ($rs) $rs->Close();
- /* suggested by Cameron, "GaM3R" <gamr@outworld.cx> */
+ // suggested by Cameron, "GaM3R" <gamr@outworld.cx>
if (defined('ADODB_SESSION_OPTIMIZE'))
{
switch( $ADODB_SESSION_DRIVER ) {
$max = ($rs) ? $rs->FieldCount() : 0;
if ($sql) $sql = urlencode($sql);
- /* metadata setup */
+ // metadata setup
- if ($max <= 0 || $rs->dataProvider == 'empty') { /* is insert/update/delete */
+ if ($max <= 0 || $rs->dataProvider == 'empty') { // is insert/update/delete
if (is_object($conn)) {
$sql .= ','.$conn->Affected_Rows();
$sql .= ','.$conn->Insert_ID();
$tt = ($rs->timeCreated) ? $rs->timeCreated : time();
$line = "====0,$tt,$sql\n";
}
- /* column definitions */
+ // column definitions
for($i=0; $i < $max; $i++) {
$o = $rs->FetchField($i);
$line .= urlencode($o->name).':'.$rs->MetaType($o->type,$o->max_length).":$o->max_length,";
$text = substr($line,0,strlen($line)-1)."\n";
- /* get data */
+ // get data
if ($rs->databaseType == 'array') {
$text .= serialize($rs->_array);
} else {
$ttl = 0;
if ($meta = fgetcsv ($fp, 8192, ",")) {
- /* check if error message */
+ // check if error message
if (substr($meta[0],0,4) === '****') {
$err = trim(substr($meta[0],4,1024));
fclose($fp);
return false;
}
- /* check for meta data */
- /* $meta[0] is -1 means return an empty recordset */
- /* $meta[1] contains a time */
+ // check for meta data
+ // $meta[0] is -1 means return an empty recordset
+ // $meta[1] contains a time
if (substr($meta[0],0,4) === '====') {
fclose($fp);
$err = "Timeout 0";
return false;
- } /* switch */
+ } // switch
- } /* if check flush cache */
- }/* (timeout>0) */
+ } // if check flush cache
+ }// (timeout>0)
$ttl = $meta[1];
}
$meta = fgetcsv($fp, 8192, ",");
}
}
- /* Get Column definitions */
+ // Get Column definitions
$flds = array();
foreach($meta as $o) {
$o2 = explode(':',$o);
} else {
fclose($fp);
$err = "Recordset had unexpected EOF 2";
- /* print "$url ";print_r($meta); */
- /* die(); */
+ //print "$url ";print_r($meta);
+ //die();
return false;
}
- /* slurp in the data */
+ // slurp in the data
$MAXSIZE = 128000;
$text = fread($fp,$MAXSIZE);
$cnt = 1;
fclose($fp);
$arr = @unserialize($text);
- /* var_dump($arr); */
+ //var_dump($arr);
if (!is_array($arr)) {
$err = "Recordset had unexpected EOF 3";
return false;
}
- /* print "<p>$s</p>"; */
+ //print "<p>$s</p>";
trigger_error($s,E_USER_ERROR);
}
?>
/*
* Enabled the following if you want to terminate scripts when an error occurs
*/
-/* PEAR::setErrorHandling (PEAR_ERROR_DIE); */
+//PEAR::setErrorHandling (PEAR_ERROR_DIE);
/*
* Name of the PEAR_Error derived class to call.
$GLOBALS['_PEAR_default_error_options'],
$errmsg);
- /* print "<p>!$s</p>"; */
+ //print "<p>!$s</p>";
}
/**
*/
-/* Requires $ADODB_FETCH_MODE = ADODB_FETCH_NUM */
+// Requires $ADODB_FETCH_MODE = ADODB_FETCH_NUM
function _adodb_getmenu(&$zthis, $name,$defstr='',$blank1stItem=true,$multiple=false,
$size=0, $selectAttr='',$compareFields0=true)
{
$s .= "\n<option".$value.'>'.htmlspecialchars($zval).'</option>';
}
$zthis->MoveNext();
- } /* while */
+ } // while
return $s ."\n</select>\n";
}
$atlastpage = false;
$lastpageno=1;
- /* If an invalid nrows is supplied, */
- /* we assume a default value of 10 rows per page */
+ // If an invalid nrows is supplied,
+ // we assume a default value of 10 rows per page
if (!isset($nrows) || $nrows <= 0) $nrows = 10;
- $qryRecs = false; /* count records for no offset */
+ $qryRecs = false; //count records for no offset
- /* jlim - attempt query rewrite first */
+ // jlim - attempt query rewrite first
$rewritesql = preg_replace(
'/^\s*SELECT\s.*\sFROM\s/is','SELECT COUNT(*) FROM ',$sql);
if ($rewritesql != $sql){
- /* fix by alexander zhukov, alex#unipack.ru, because count(*) and 'order by' fails */
- /* with mssql, access and postgresql */
+ // fix by alexander zhukov, alex#unipack.ru, because count(*) and 'order by' fails
+ // with mssql, access and postgresql
$rewritesql = preg_replace('/(\sORDER\s+BY\s.*)/is','',$rewritesql);
if ($secs2cache) {
- /* we only use half the time of secs2cache because the count can quickly */
- /* become inaccurate if new records are added */
+ // we only use half the time of secs2cache because the count can quickly
+ // become inaccurate if new records are added
$rs = $zthis->CacheExecute($secs2cache/2,$rewritesql);
if ($rs) {
if (!$rs->EOF) $qryRecs = reset($rs->fields);
$lastpageno = (int) ceil($qryRecs / $nrows);
}
- /* query rewrite failed - so try slower way... */
+ // query rewrite failed - so try slower way...
if ($qryRecs === false) {
$rstest = &$zthis->Execute($sql);
if ($rstest) {
- /* save total records */
+ //save total records
$qryRecs = $rstest->RecordCount();
if ($qryRecs == -1)
if (!$rstest->EOF) {
$zthis->_maxRecordCount = $qryRecs;
- /* If page number <= 1, then we are at the first page */
+ // If page number <= 1, then we are at the first page
if (!isset($page) || $page <= 1) {
$page = 1;
$atfirstpage = true;
}
- /* ***** Here we check whether $page is the last page or */
- /* whether we are trying to retrieve */
- /* a page number greater than the last page number. */
+ // ***** Here we check whether $page is the last page or
+ // whether we are trying to retrieve
+ // a page number greater than the last page number.
if ($page >= $lastpageno) {
$page = $lastpageno;
$atlastpage = true;
}
- /* We get the data we want */
+ // We get the data we want
$offset = $nrows * ($page-1);
if ($secs2cache > 0)
$rsreturn = &$zthis->CacheSelectLimit($secs2cache, $sql, $nrows, $offset, $inputarr, $arg3);
$rsreturn = &$zthis->SelectLimit($sql, $nrows, $offset, $inputarr, $arg3, $secs2cache);
- /* Before returning the RecordSet, we set the pagination properties we need */
+ // Before returning the RecordSet, we set the pagination properties we need
if ($rsreturn) {
$rsreturn->rowsPerPage = $nrows;
$rsreturn->AbsolutePage($page);
return $rsreturn;
}
-/* Iván Oliva version */
+// Iván Oliva version
function &_adodb_pageexecute_no_last_page(&$zthis, $sql, $nrows, $page, $inputarr=false, $arg3=false, $secs2cache=0)
{
$atfirstpage = false;
$atlastpage = false;
- if (!isset($page) || $page <= 1) { /* If page number <= 1, then we are at the first page */
+ if (!isset($page) || $page <= 1) { // If page number <= 1, then we are at the first page
$page = 1;
$atfirstpage = true;
}
- if ($nrows <= 0) $nrows = 10; /* If an invalid nrows is supplied, we assume a default value of 10 rows per page */
+ if ($nrows <= 0) $nrows = 10; // If an invalid nrows is supplied, we assume a default value of 10 rows per page
- /* ***** Here we check whether $page is the last page or whether we are trying to retrieve a page number greater than */
- /* the last page number. */
+ // ***** Here we check whether $page is the last page or whether we are trying to retrieve a page number greater than
+ // the last page number.
$pagecounter = $page + 1;
$pagecounteroffset = ($pagecounter * $nrows) - $nrows;
if ($secs2cache>0) $rstest = &$zthis->CacheSelectLimit($secs2cache, $sql, $nrows, $pagecounteroffset, $inputarr, $arg3);
}
if ($rstest) $rstest->Close();
}
- if ($atlastpage) { /* If we are at the last page or beyond it, we are going to retrieve it */
+ if ($atlastpage) { // If we are at the last page or beyond it, we are going to retrieve it
$page = $pagecounter;
- if ($page == 1) $atfirstpage = true; /* We have to do this again in case the last page is the same as the first */
- /* ... page, that is, the recordset has only 1 page. */
+ if ($page == 1) $atfirstpage = true; // We have to do this again in case the last page is the same as the first
+ //... page, that is, the recordset has only 1 page.
}
- /* We get the data we want */
+ // We get the data we want
$offset = $nrows * ($page-1);
if ($secs2cache > 0) $rsreturn = &$zthis->CacheSelectLimit($secs2cache, $sql, $nrows, $offset, $inputarr, $arg3);
else $rsreturn = &$zthis->SelectLimit($sql, $nrows, $offset, $inputarr, $arg3, $secs2cache);
- /* Before returning the RecordSet, we set the pagination properties we need */
+ // Before returning the RecordSet, we set the pagination properties we need
if ($rsreturn) {
$rsreturn->rowsPerPage = $nrows;
$rsreturn->AbsolutePage($page);
$fieldUpdatedCount = 0;
- /* Get the table name from the existing query. */
+ // Get the table name from the existing query.
preg_match("/FROM\s".ADODB_TABLE_REGEX."/i", $rs->sql, $tableName);
- /* Get the full where clause excluding the word "WHERE" from */
- /* the existing query. */
+ // Get the full where clause excluding the word "WHERE" from
+ // the existing query.
preg_match("/WHERE\s(.*)/i", $rs->sql, $whereClause);
- /* updateSQL will contain the full update query when all */
- /* processing has completed. */
+ // updateSQL will contain the full update query when all
+ // processing has completed.
$updateSQL = "UPDATE " . $tableName[1] . " SET ";
- /* Loop through all of the fields in the recordset */
+ // Loop through all of the fields in the recordset
for ($i=0, $max=$rs->FieldCount(); $i < $max; $i++) {
- /* Get the field from the recordset */
+ // Get the field from the recordset
$field = $rs->FetchField($i);
- /* If the recordset field is one */
- /* of the fields passed in then process. */
+ // If the recordset field is one
+ // of the fields passed in then process.
if (isset($arrFields[$field->name])) {
- /* If the existing field value in the recordset */
- /* is different from the value passed in then */
- /* go ahead and append the field name and new value to */
- /* the update query. */
+ // If the existing field value in the recordset
+ // is different from the value passed in then
+ // go ahead and append the field name and new value to
+ // the update query.
if ($forceUpdate || strcmp($rs->fields[$i], $arrFields[$field->name])) {
- /* Set the counter for the number of fields that will be updated. */
+ // Set the counter for the number of fields that will be updated.
$fieldUpdatedCount++;
- /* Based on the datatype of the field */
- /* Format the value properly for the database */
+ // Based on the datatype of the field
+ // Format the value properly for the database
$mt = $rs->MetaType($field->type);
- /* "mike" <mike@partner2partner.com> patch and "Ryan Bailey" <rebel@windriders.com> */
- /* PostgreSQL uses a 't' or 'f' and therefore needs to be processed as a string ('C') type field. */
+ // "mike" <mike@partner2partner.com> patch and "Ryan Bailey" <rebel@windriders.com>
+ //PostgreSQL uses a 't' or 'f' and therefore needs to be processed as a string ('C') type field.
if ((substr($zthis->databaseType,0,8) == "postgres") && ($mt == "L")) $mt = "C";
switch($mt) {
};
};
- /* If there were any modified fields then build the rest of the update query. */
+ // If there were any modified fields then build the rest of the update query.
if ($fieldUpdatedCount > 0 || $forceUpdate) {
- /* Strip off the comma and space on the end of the update query. */
+ // Strip off the comma and space on the end of the update query.
$updateSQL = substr($updateSQL, 0, -2);
- /* If the recordset has a where clause then use that same where clause */
- /* for the update. */
+ // If the recordset has a where clause then use that same where clause
+ // for the update.
if ($whereClause[1]) $updateSQL .= " WHERE " . $whereClause[1];
return $updateSQL;
$fieldInsertedCount = 0;
- /* Get the table name from the existing query. */
+ // Get the table name from the existing query.
preg_match("/FROM\s".ADODB_TABLE_REGEX."/i", $rs->sql, $tableName);
- /* Loop through all of the fields in the recordset */
+ // Loop through all of the fields in the recordset
for ($i=0, $max=$rs->FieldCount(); $i < $max; $i++) {
- /* Get the field from the recordset */
+ // Get the field from the recordset
$field = $rs->FetchField($i);
- /* If the recordset field is one */
- /* of the fields passed in then process. */
+ // If the recordset field is one
+ // of the fields passed in then process.
if (isset($arrFields[$field->name])) {
- /* Set the counter for the number of fields that will be inserted. */
+ // Set the counter for the number of fields that will be inserted.
$fieldInsertedCount++;
- /* Get the name of the fields to insert */
+ // Get the name of the fields to insert
$fields .= $field->name . ", ";
$mt = $rs->MetaType($field->type);
- /* "mike" <mike@partner2partner.com> patch and "Ryan Bailey" <rebel@windriders.com> */
- /* PostgreSQL uses a 't' or 'f' and therefore needs to be processed as a string ('C') type field. */
+ // "mike" <mike@partner2partner.com> patch and "Ryan Bailey" <rebel@windriders.com>
+ //PostgreSQL uses a 't' or 'f' and therefore needs to be processed as a string ('C') type field.
if ((substr($zthis->databaseType,0,8) == "postgres") && ($mt == "L")) $mt = "C";
- /* Based on the datatype of the field */
- /* Format the value properly for the database */
+ // Based on the datatype of the field
+ // Format the value properly for the database
switch($mt) {
case "C":
case "X":
};
};
- /* If there were any inserted fields then build the rest of the insert query. */
+ // If there were any inserted fields then build the rest of the insert query.
if ($fieldInsertedCount > 0) {
- /* Strip off the comma and space on the end of both the fields */
- /* and their values. */
+ // Strip off the comma and space on the end of both the fields
+ // and their values.
$fields = substr($fields, 0, -2);
$values = substr($values, 0, -2);
- /* Append the fields and their values to the insert query. */
+ // Append the fields and their values to the insert query.
$insertSQL = "INSERT INTO " . $tableName[1] . " ( $fields ) VALUES ( $values )";
return $insertSQL;
delete records.
*/
class ADODB_Pager {
- var $id; /* unique id for pager (defaults to 'adodb') */
- var $db; /* ADODB connection object */
- var $sql; /* sql used */
- var $rs; /* recordset generated */
- var $curr_page; /* current page number before Render() called, calculated in constructor */
- var $rows; /* number of rows per page */
+ var $id; // unique id for pager (defaults to 'adodb')
+ var $db; // ADODB connection object
+ var $sql; // sql used
+ var $rs; // recordset generated
+ var $curr_page; // current page number before Render() called, calculated in constructor
+ var $rows; // number of rows per page
var $gridAttributes = 'width=100% border=1 bgcolor=white';
- /* Localize text strings here */
+ // Localize text strings here
var $first = '<code>|<</code>';
var $prev = '<code><<</code>';
var $next = '<code>>></code>';
var $page = 'Page';
var $cache = 0; #secs to cache with CachePageExecute()
- /* ---------------------------------------------- */
- /* constructor */
- /* */
- /* $db adodb connection object */
- /* $sql sql statement */
- /* $id optional id to identify which pager, */
- /* if you have multiple on 1 page. */
- /* $id should be only be [a-z0-9]* */
- /* */
+ //----------------------------------------------
+ // constructor
+ //
+ // $db adodb connection object
+ // $sql sql statement
+ // $id optional id to identify which pager,
+ // if you have multiple on 1 page.
+ // $id should be only be [a-z0-9]*
+ //
function ADODB_Pager(&$db,$sql,$id = 'adodb')
{
global $HTTP_SERVER_VARS,$PHP_SELF,$HTTP_SESSION_VARS,$HTTP_GET_VARS;
}
- /* --------------------------- */
- /* Display link to first page */
+ //---------------------------
+ // Display link to first page
function Render_First($anchor=true)
{
global $PHP_SELF;
}
}
- /* -------------------------- */
- /* Display link to next page */
+ //--------------------------
+ // Display link to next page
function render_next($anchor=true)
{
global $PHP_SELF;
}
}
- /* ------------------ */
- /* Link to last page */
- /* */
- /* for better performance with large recordsets, you can set */
- /* $this->db->pageExecuteCountRows = false, which disables */
- /* last page counting. */
+ //------------------
+ // Link to last page
+ //
+ // for better performance with large recordsets, you can set
+ // $this->db->pageExecuteCountRows = false, which disables
+ // last page counting.
function render_last($anchor=true)
{
global $PHP_SELF;
}
}
- /* ---------------------- */
- /* Link to previous page */
+ //----------------------
+ // Link to previous page
function render_prev($anchor=true)
{
global $PHP_SELF;
}
}
- /* -------------------------------------------------------- */
- /* Simply rendering of grid. You should override this for */
- /* better control over the format of the grid */
- /* */
- /* We use output buffering to keep code clean and readable. */
+ //--------------------------------------------------------
+ // Simply rendering of grid. You should override this for
+ // better control over the format of the grid
+ //
+ // We use output buffering to keep code clean and readable.
function RenderGrid()
{
- global $gSQLBlockRows; /* used by rs2html to indicate how many rows to display */
+ global $gSQLBlockRows; // used by rs2html to indicate how many rows to display
include_once(ADODB_DIR.'/tohtml.inc.php');
ob_start();
$gSQLBlockRows = $this->rows;
return $s;
}
- /* ------------------------------------------------------- */
- /* Navigation bar */
- /* */
- /* we use output buffering to keep the code easy to read. */
+ //-------------------------------------------------------
+ // Navigation bar
+ //
+ // we use output buffering to keep the code easy to read.
function RenderNav()
{
ob_start();
return $s;
}
- /* ------------------- */
- /* This is the footer */
+ //-------------------
+ // This is the footer
function RenderPageCount()
{
if (!$this->db->pageExecuteCountRows) return '';
return "<font size=-1>$this->page ".$this->curr_page."/".$this->rs->LastPageNo()."</font>";
}
- /* ----------------------------------- */
- /* Call this class to draw everything. */
+ //-----------------------------------
+ // Call this class to draw everything.
function Render($rows=10)
{
global $ADODB_COUNTRECS;
$this->RenderLayout($header,$grid,$footer);
}
- /* ------------------------------------------------------ */
- /* override this to control overall layout and formating */
+ //------------------------------------------------------
+ // override this to control overall layout and formating
function RenderLayout($header,$grid,$footer)
{
echo "<table border=1 bgcolor=beige><tr><td>",
if (is_array($options) && isset($options["debug"]) &&
$options["debug"] >= 2) {
- /* expose php errors with sufficient debug level */
+ // expose php errors with sufficient debug level
@include_once("adodb-$type.inc.php");
} else {
@include_once("adodb-$type.inc.php");
'password' => false
);
- /* Find phptype and dbsyntax */
- if (($pos = strpos($dsn, ':/* ')) !== false) { */
+ // Find phptype and dbsyntax
+ if (($pos = strpos($dsn, '://')) !== false) {
$str = substr($dsn, 0, $pos);
$dsn = substr($dsn, $pos + 3);
} else {
$dsn = NULL;
}
- /* Get phptype and dbsyntax */
- /* $str => phptype(dbsyntax) */
+ // Get phptype and dbsyntax
+ // $str => phptype(dbsyntax)
if (preg_match('|^(.+?)\((.*?)\)$|', $str, $arr)) {
$parsed['phptype'] = $arr[1];
$parsed['dbsyntax'] = (empty($arr[2])) ? $arr[1] : $arr[2];
return $parsed;
}
- /* Get (if found): username and password */
- /* $dsn => username:password@protocol+hostspec/database */
+ // Get (if found): username and password
+ // $dsn => username:password@protocol+hostspec/database
if (($at = strpos($dsn,'@')) !== false) {
$str = substr($dsn, 0, $at);
$dsn = substr($dsn, $at + 1);
}
}
- /* Find protocol and hostspec */
- /* $dsn => protocol+hostspec/database */
+ // Find protocol and hostspec
+ // $dsn => protocol+hostspec/database
if (($pos=strpos($dsn, '/')) !== false) {
$str = substr($dsn, 0, $pos);
$dsn = substr($dsn, $pos + 1);
$dsn = NULL;
}
- /* Get protocol + hostspec */
- /* $str => protocol+hostspec */
+ // Get protocol + hostspec
+ // $str => protocol+hostspec
if (($pos=strpos($str, '+')) !== false) {
$parsed['protocol'] = substr($str, 0, $pos);
$parsed['hostspec'] = urldecode(substr($str, $pos + 1));
$parsed['hostspec'] = urldecode($str);
}
- /* Get dabase if any */
- /* $dsn => database */
+ // Get dabase if any
+ // $dsn => database
if (!empty($dsn)) {
$parsed['database'] = $dsn;
}
$ADODB_SESS_LIFE = get_cfg_var('session.gc_maxlifetime');
if ($ADODB_SESS_LIFE <= 1) {
- /* bug in PHP 4.0.3 pl 1 -- how about other versions? */
- /* print "<h3>Session Error: PHP.INI setting <i>session.gc_maxlifetime</i>not set: $ADODB_SESS_LIFE</h3>"; */
+ // bug in PHP 4.0.3 pl 1 -- how about other versions?
+ //print "<h3>Session Error: PHP.INI setting <i>session.gc_maxlifetime</i>not set: $ADODB_SESS_LIFE</h3>";
$ADODB_SESS_LIFE=1440;
}
$ADODB_SESSION_CRC = false;
- /* $ADODB_SESS_DEBUG = true; */
+ //$ADODB_SESS_DEBUG = true;
- /* //////////////////////////////// */
+ //////////////////////////////////
/* SET THE FOLLOWING PARAMETERS */
- /* //////////////////////////////// */
+ //////////////////////////////////
if (empty($ADODB_SESSION_DRIVER)) {
$ADODB_SESSION_DRIVER='mysql';
$ADODB_SESSION_DB ='xphplens_2';
}
- /* Made table name configurable - by David Johnson djohnson@inpro.net */
+ // Made table name configurable - by David Johnson djohnson@inpro.net
if (empty($ADODB_SESSION_TBL)){
$ADODB_SESSION_TBL = 'sessions';
}
function adodb_sess_open($save_path, $session_name,$persist=true)
{
GLOBAL $ADODB_SESS_CONN;
- /* if( $persist) print "PERSIST "; */
+ //if( $persist) print "PERSIST ";
if (isset($ADODB_SESS_CONN)) return true;
GLOBAL $ADODB_SESSION_CONNECT,
$ADODB_SESSION_DB,
$ADODB_SESS_DEBUG;
- /* cannot use & below - do not know why... */
+ // cannot use & below - do not know why...
$ADODB_SESS_CONN = ADONewConnection($ADODB_SESSION_DRIVER);
if (!empty($ADODB_SESS_DEBUG)) {
$ADODB_SESS_CONN->debug = true;
$rs->Close();
- /* new optimization adodb 2.1 */
+ // new optimization adodb 2.1
$ADODB_SESSION_CRC = crc32($v);
return $v;
}
else $ADODB_SESS_INSERT = true;
- return ''; /* thx to Jorma Tuomainen, webmaster#wizactive.com */
+ return ''; // thx to Jorma Tuomainen, webmaster#wizactive.com
}
/****************************************************************************************\
$expiry = time() + $ADODB_SESS_LIFE;
- /* new optimization adodb 2.1 */
+ // new optimization adodb 2.1
if ($ADODB_SESSION_CRC !== false && $ADODB_SESSION_CRC == crc32($val)) {
if ($ADODB_SESS_DEBUG) echo "<p>Session: No need to update - crc32 not changed</p>";
return true;
if ($rs) $rs->Close();
else print '<p>Session Insert: '.$ADODB_SESS_CONN->ErrorMsg().'</p>';
}
- /* bug in access driver (could be odbc?) means that info is not commited */
- /* properly unless select statement executed in Win2000 */
+ // bug in access driver (could be odbc?) means that info is not commited
+ // properly unless select statement executed in Win2000
if ($ADODB_SESS_CONN->databaseType == 'access') $rs = $ADODB_SESS_CONN->Execute("select sesskey from $ADODB_SESSION_TBL WHERE sesskey='$key'");
return isset($rs);
$rs = $ADODB_SESS_CONN->Execute($qry);
if ($rs) $rs->Close();
- /* suggested by Cameron, "GaM3R" <gamr@outworld.cx> */
+ // suggested by Cameron, "GaM3R" <gamr@outworld.cx>
if (defined('ADODB_SESSION_OPTIMIZE'))
{
switch( $ADODB_SESSION_DRIVER ) {
if (!defined('_ADODB_LAYER')) {
define('_ADODB_LAYER',1);
- /* ============================================================================================== */
- /* CONSTANT DEFINITIONS */
- /* ============================================================================================== */
+ //==============================================================================================
+ // CONSTANT DEFINITIONS
+ //==============================================================================================
define('ADODB_BAD_RS','<p>Bad $rs in %s. Connection or SQL invalid. Try using $connection->debug=true;</p>');
define('ADODB_FETCH_ASSOC',2);
define('ADODB_FETCH_BOTH',3);
- /* allow [ ] @ and . in table names */
+ // allow [ ] @ and . in table names
define('ADODB_TABLE_REGEX','([]0-9a-z_\.\@\[-]*)');
- if (!defined('MAX_BLOB_SIZE')) define('MAX_BLOB_SIZE',999999); /* 900K */
+ if (!defined('MAX_BLOB_SIZE')) define('MAX_BLOB_SIZE',999999); // 900K
if (!defined('ADODB_PREFETCH_ROWS')) define('ADODB_PREFETCH_ROWS',10);
if (!defined('ADODB_DIR')) define('ADODB_DIR',dirname(__FILE__));
if (strpos(strtoupper(PHP_OS),'WIN') !== false) {
- /* windows, negative timestamps are illegal as of php 4.2.0 */
+ // windows, negative timestamps are illegal as of php 4.2.0
define('TIMESTAMP_FIRST_YEAR',1970);
} else
define('TIMESTAMP_FIRST_YEAR',1904);
- /* ============================================================================================== */
- /* GLOBAL VARIABLES */
- /* ============================================================================================== */
+ //==============================================================================================
+ // GLOBAL VARIABLES
+ //==============================================================================================
GLOBAL
- $ADODB_vers, /* database version */
- $ADODB_Database, /* last database driver used */
- $ADODB_COUNTRECS, /* count number of records returned - slows down query */
- $ADODB_CACHE_DIR, /* directory to cache recordsets */
- $ADODB_FETCH_MODE; /* DEFAULT, NUM, ASSOC or BOTH. Default follows native driver default... */
+ $ADODB_vers, // database version
+ $ADODB_Database, // last database driver used
+ $ADODB_COUNTRECS, // count number of records returned - slows down query
+ $ADODB_CACHE_DIR, // directory to cache recordsets
+ $ADODB_FETCH_MODE; // DEFAULT, NUM, ASSOC or BOTH. Default follows native driver default...
- /* ============================================================================================== */
- /* GLOBAL SETUP */
- /* ============================================================================================== */
+ //==============================================================================================
+ // GLOBAL SETUP
+ //==============================================================================================
$ADODB_FETCH_MODE = ADODB_FETCH_DEFAULT;
if (!isset($ADODB_CACHE_DIR)) {
$ADODB_CACHE_DIR = '/tmp';
} else {
- /* do not accept url based paths, eg. http:/ or ftp:/ */
- if (strpos($ADODB_CACHE_DIR,':/* ') !== false) */
- die("Illegal path http:/* or ftp://"); */
+ // do not accept url based paths, eg. http:/ or ftp:/
+ if (strpos($ADODB_CACHE_DIR,'://') !== false)
+ die("Illegal path http:// or ftp://");
}
- /* ============================================================================================== */
- /* CHANGE NOTHING BELOW UNLESS YOU ARE CODING */
- /* ============================================================================================== */
+ //==============================================================================================
+ // CHANGE NOTHING BELOW UNLESS YOU ARE CODING
+ //==============================================================================================
- /* Initialize random number generator for randomizing cache flushes */
+ // Initialize random number generator for randomizing cache flushes
srand(((double)microtime())*1000000);
/**
*/
$ADODB_COUNTRECS = true;
- /* ============================================================================================== */
- /* CLASS ADOFieldObject */
- /* ============================================================================================== */
+ //==============================================================================================
+ // CLASS ADOFieldObject
+ //==============================================================================================
/**
* Helper class for FetchFields -- holds info on a column
var $max_length=0;
var $type="";
- /* additional fields by dannym... (danny_milo@yahoo.com) */
+ // additional fields by dannym... (danny_milo@yahoo.com)
var $not_null = false;
- /* actually, this has already been built-in in the postgres, fbsql AND mysql module? ^-^ */
- /* so we can as well make not_null standard (leaving it at "false" does not harm anyways) */
+ // actually, this has already been built-in in the postgres, fbsql AND mysql module? ^-^
+ // so we can as well make not_null standard (leaving it at "false" does not harm anyways)
- var $has_default = false; /* this one I have done only in mysql and postgres for now ... */
- /* others to come (dannym) */
- var $default_value; /* default, if any, and supported. Check has_default first. */
+ var $has_default = false; // this one I have done only in mysql and postgres for now ...
+ // others to come (dannym)
+ var $default_value; // default, if any, and supported. Check has_default first.
}
- /* ============================================================================================== */
- /* CLASS ADOConnection */
- /* ============================================================================================== */
+ //==============================================================================================
+ // CLASS ADOConnection
+ //==============================================================================================
/**
* Connection object. For connecting to databases, and executing queries.
* PUBLIC VARS
*/
var $dataProvider = 'native';
- var $databaseType = ''; /* RDBMS currently in use, eg. odbc, mysql, mssql */
- var $database = ''; /* Name of database to be used. */
- var $host = ''; /* The hostname of the database server */
- var $user = ''; /* The username which is used to connect to the database server. */
- var $password = ''; /* Password for the username */
- var $debug = false; /* if set to true will output sql statements */
- var $maxblobsize = 64000; /* maximum size of blobs or large text fields -- some databases die otherwise like foxpro */
- var $concat_operator = '+'; /* default concat operator -- change to || for Oracle/Interbase */
- var $fmtDate = "'Y-m-d'"; /* used by DBDate() as the default date format used by the database */
- var $fmtTimeStamp = "'Y-m-d, h:i:s A'"; /* used by DBTimeStamp as the default timestamp fmt. */
- var $true = '1'; /* string that represents TRUE for a database */
- var $false = '0'; /* string that represents FALSE for a database */
- var $replaceQuote = "\\'"; /* string to use to replace quotes */
- var $hasInsertID = false; /* supports autoincrement ID? */
- var $hasAffectedRows = false; /* supports affected rows for update/delete? */
- var $charSet=false; /* character set to use - only for interbase */
+ var $databaseType = ''; // RDBMS currently in use, eg. odbc, mysql, mssql
+ var $database = ''; // Name of database to be used.
+ var $host = ''; // The hostname of the database server
+ var $user = ''; // The username which is used to connect to the database server.
+ var $password = ''; // Password for the username
+ var $debug = false; // if set to true will output sql statements
+ var $maxblobsize = 64000; // maximum size of blobs or large text fields -- some databases die otherwise like foxpro
+ var $concat_operator = '+'; // default concat operator -- change to || for Oracle/Interbase
+ var $fmtDate = "'Y-m-d'"; // used by DBDate() as the default date format used by the database
+ var $fmtTimeStamp = "'Y-m-d, h:i:s A'"; // used by DBTimeStamp as the default timestamp fmt.
+ var $true = '1'; // string that represents TRUE for a database
+ var $false = '0'; // string that represents FALSE for a database
+ var $replaceQuote = "\\'"; // string to use to replace quotes
+ var $hasInsertID = false; // supports autoincrement ID?
+ var $hasAffectedRows = false; // supports affected rows for update/delete?
+ var $charSet=false; // character set to use - only for interbase
var $metaTablesSQL = '';
- var $hasTop = false; /* support mssql/access SELECT TOP 10 * FROM TABLE */
- var $hasLimit = false; /* support pgsql/mysql SELECT * FROM TABLE LIMIT 10 */
- var $readOnly = false; /* this is a readonly database - used by phpLens */
- var $hasMoveFirst = false; /* has ability to run MoveFirst(), scrolling backwards */
- var $hasGenID = false; /* can generate sequences using GenID(); */
- var $genID = 0; /* sequence id used by GenID(); */
- var $raiseErrorFn = false; /* error function to call */
- var $upperCase = false; /* uppercase function to call for searching/where */
- var $isoDates = false; /* accepts dates in ISO format */
- var $cacheSecs = 3600; /* cache for 1 hour */
- var $sysDate = false; /* name of function that returns the current date */
- var $sysTimeStamp = false; /* name of function that returns the current timestamp */
+ var $hasTop = false; // support mssql/access SELECT TOP 10 * FROM TABLE
+ var $hasLimit = false; // support pgsql/mysql SELECT * FROM TABLE LIMIT 10
+ var $readOnly = false; // this is a readonly database - used by phpLens
+ var $hasMoveFirst = false; // has ability to run MoveFirst(), scrolling backwards
+ var $hasGenID = false; // can generate sequences using GenID();
+ var $genID = 0; // sequence id used by GenID();
+ var $raiseErrorFn = false; // error function to call
+ var $upperCase = false; // uppercase function to call for searching/where
+ var $isoDates = false; // accepts dates in ISO format
+ var $cacheSecs = 3600; // cache for 1 hour
+ var $sysDate = false; // name of function that returns the current date
+ var $sysTimeStamp = false; // name of function that returns the current timestamp
var $arrayClass = 'ADORecordSet_array';
- /* oracle specific stuff */
+ // oracle specific stuff
var $noNullStrings = false;
var $numCacheHits = 0;
var $numCacheMisses = 0;
var $pageExecuteCountRows = true;
- var $uniqueSort = false; /* indicates that all fields in order by must be unique */
+ var $uniqueSort = false; // indicates that all fields in order by must be unique
/*
* PRIVATE VARS
*/
- var $_connectionID = false; /* The returned link identifier whenever a successful database connection is made. */ */
+ var $_connectionID = false; // The returned link identifier whenever a successful database connection is made. */
- var $_errorMsg = ''; /* A variable which was used to keep the returned last error message. The value will */
- /* then returned by the errorMsg() function */
+ var $_errorMsg = ''; // A variable which was used to keep the returned last error message. The value will
+ //then returned by the errorMsg() function
- var $_queryID = false; /* This variable keeps the last created result link identifier. */ */
+ var $_queryID = false; // This variable keeps the last created result link identifier. */
- var $_isPersistentConnection = false; /* A boolean variable to state whether its a persistent connection or normal connection. */ */
+ var $_isPersistentConnection = false; // A boolean variable to state whether its a persistent connection or normal connection. */
- var $_bindInputArray = false; /* set to true if ADOConnection.Execute() permits binding of array parameters. */
+ var $_bindInputArray = false; // set to true if ADOConnection.Execute() permits binding of array parameters.
- var $autoCommit = true; /* do not modify this yourself - actually private */
+ var $autoCommit = true; // do not modify this yourself - actually private
/**
* Constructor
{
if ($argHostname != "") $this->host = $argHostname;
if ($argUsername != "") $this->user = $argUsername;
- if ($argPassword != "") $this->password = $argPassword; /* not stored for security reasons */
+ if ($argPassword != "") $this->password = $argPassword; // not stored for security reasons
if ($argDatabaseName != "") $this->database = $argDatabaseName;
$this->_isPersistentConnection = false;
*/
function &LimitQuery($sql, $offset, $count)
{
- $rs = &$this->SelectLimit($sql, $count, $offset); /* swap */
+ $rs = &$this->SelectLimit($sql, $count, $offset); // swap
if (!$rs && defined('ADODB_PEAR')) return ADODB_PEAR_Error();
return $rs;
}
foreach($inputarr as $v) {
$sql .= $sqlarr[$i];
- /* from Ron Baldwin <ron.baldwin@sourceprose.com> */
- /* Only quote string types */
+ // from Ron Baldwin <ron.baldwin@sourceprose.com>
+ // Only quote string types
if (gettype($v) == 'string')
$sql .= $this->qstr($v);
else if ($v === null)
$inputarr = false;
}
- /* debug version of query */
+ // debug version of query
if ($this->debug) {
global $HTTP_SERVER_VARS;
if (is_array($sql)) $sqlTxt = $sql[0];
else $sqlTxt = $sql;
- /* check if running from browser or command-line */
+ // check if running from browser or command-line
$inBrowser = isset($HTTP_SERVER_VARS['HTTP_USER_AGENT']);
if ($inBrowser)
because ErrorNo() calls Execute('SELECT @ERROR'), causing recure
*/
if ($this->databaseType == 'mssql') {
- /* ErrorNo is a slow function call in mssql, and not reliable */
- /* in PHP 4.0.6 */
+ // ErrorNo is a slow function call in mssql, and not reliable
+ // in PHP 4.0.6
if($emsg = $this->ErrorMsg()) {
$err = $this->ErrorNo();
if ($err) {
flush();
}
} else
- /* non-debug version of query */
+ // non-debug version of query
$this->_queryID =@$this->_query($sql,$inputarr,$arg3);
- /* error handling if query fails */
+ // error handling if query fails
if ($this->_queryID === false) {
if ($fn = $this->raiseErrorFn) {
$fn($this->databaseType,'EXECUTE',$this->ErrorNo(),$this->ErrorMsg(),$sql,$inputarr);
}
return false;
} else if ($this->_queryID === true){
- /* return simplified empty recordset for inserts/updates/deletes with lower overhead */
+ // return simplified empty recordset for inserts/updates/deletes with lower overhead
$rs = new ADORecordSet_empty();
return $rs;
}
- /* return real recordset from select statement */
+ // return real recordset from select statement
$rsclass = "ADORecordSet_".$this->databaseType;
- $rs = new $rsclass($this->_queryID); /* &new not supported by older PHP versions */
- $rs->connection = &$this; /* Pablo suggestion */
+ $rs = new $rsclass($this->_queryID); // &new not supported by older PHP versions
+ $rs->connection = &$this; // Pablo suggestion
$rs->Init();
if (is_array($sql)) $rs->sql = $sql[0];
function GenID($seqname='adodbseq',$startID=1)
{
if (!$this->hasGenID) {
- return 0; /* formerly returns false pre 1.60 */
+ return 0; // formerly returns false pre 1.60
}
$getnext = sprintf($this->_genIDSQL,$seqname);
$rs = $this->Execute($getnext);
}
if ($rs && !$rs->EOF) $this->genID = (integer) reset($rs->fields);
- else $this->genID = 0; /* false */
+ else $this->genID = 0; // false
if ($rs) $rs->Close();
function &SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$arg3=false,$secs2cache=0)
{
if ($this->hasTop && $nrows > 0) {
- /* suggested by Reinhard Balling. Access requires top after distinct */
+ // suggested by Reinhard Balling. Access requires top after distinct
if ($offset <= 0) {
$sql = preg_replace(
}
- /* if $offset>0, we want to skip rows, and $ADODB_COUNTRECS is set, we buffer rows */
- /* 0 to offset-1 which will be discarded anyway. So we disable $ADODB_COUNTRECS. */
+ // if $offset>0, we want to skip rows, and $ADODB_COUNTRECS is set, we buffer rows
+ // 0 to offset-1 which will be discarded anyway. So we disable $ADODB_COUNTRECS.
global $ADODB_COUNTRECS;
$savec = $ADODB_COUNTRECS;
if ($rs && !$rs->EOF) {
return $this->_rs2rs($rs,$nrows,$offset);
}
- /* print_r($rs); */
+ //print_r($rs);
return $rs;
}
$v = $this->qstr($v);
$fieldArray[$k] = $v;
}
- if (in_array($k,$keyCol)) continue; /* skip UPDATE if is key */
+ if (in_array($k,$keyCol)) continue; // skip UPDATE if is key
if ($first) {
$first = false;
if (!is_numeric($secs2cache)) {
if ($sql === false) $sql = -1;
if ($offset == -1) $offset = false;
- /* sql, nrows, offset,inputarr,arg3 */
+ // sql, nrows, offset,inputarr,arg3
return $this->SelectLimit($secs2cache,$sql,$nrows,$offset,$inputarr,$this->cacheSecs);
}
if ($sql === false) echo "Warning: \$sql missing from CacheSelectLimit()<br />\n";
function CacheFlush($sql)
{
$f = $this->_gencachename($sql,false);
- adodb_write_file($f,''); /* is adodb_write_file needed? */
+ adodb_write_file($f,''); // is adodb_write_file needed?
@unlink($f);
}
$secs2cache = $this->cacheSecs;
}
include_once(ADODB_DIR.'/adodb-csvlib.inc.php');
- /* cannot cache if $inputarr set */
+ // cannot cache if $inputarr set
if ($inputarr) return $this->Execute($sql, $inputarr, $arg3);
$md5file = $this->_gencachename($sql,true);
}
if (!$rs) {
- /* no cached rs found */
+ // no cached rs found
if ($this->debug) print " $md5file cache failure: $err<br>\n";
$rs = &$this->Execute($sql,$inputarr,$arg3);
if ($rs) {
$eof = $rs->EOF;
- $rs = &$this->_rs2rs($rs); /* read entire recordset into memory immediately */
- $txt = _rs2serialize($rs,false,$sql); /* serialize */
+ $rs = &$this->_rs2rs($rs); // read entire recordset into memory immediately
+ $txt = _rs2serialize($rs,false,$sql); // serialize
if (!adodb_write_file($md5file,$txt,$this->debug)) {
if ($fn = $this->raiseErrorFn) {
}
if ($rs->EOF && !$eof) {
$rs->MoveFirst();
- /* $rs = &csv2rs($md5file,$err); */
- $rs->connection = &$this; /* Pablo suggestion */
+ //$rs = &csv2rs($md5file,$err);
+ $rs->connection = &$this; // Pablo suggestion
}
} else
@unlink($md5file);
} else {
- /* ok, set cached object found */
- $rs->connection = &$this; /* Pablo suggestion */
+ // ok, set cached object found
+ $rs->connection = &$this; // Pablo suggestion
if ($this->debug){
$ttl = $rs->timeCreated + $secs2cache - time();
print " $md5file reloaded, ttl=$ttl<br>\n";
*/
function CharMax()
{
- return 255; /* make it conservative if not defined */
+ return 255; // make it conservative if not defined
}
*/
function TextMax()
{
- return 4000; /* make it conservative if not defined */
+ return 4000; // make it conservative if not defined
}
{
return $this->_close();
- /* "Simon Lee" <simon@mediaroad.com> reports that persistent connections need */
- /* to be closed too! */
- /* if ($this->_isPersistentConnection != true) return $this->_close(); */
- /* else return true; */
+ // "Simon Lee" <simon@mediaroad.com> reports that persistent connections need
+ // to be closed too!
+ //if ($this->_isPersistentConnection != true) return $this->_close();
+ //else return true;
}
if ($rs === false) return false;
$retarr = array();
- while (!$rs->EOF) { /* print_r($rs->fields); */
+ while (!$rs->EOF) { //print_r($rs->fields);
$fld = new ADOFieldObject();
$fld->name = $rs->fields[0];
$fld->type = $rs->fields[1];
($v), $rr)) return false;
if ($rr[1] <= TIMESTAMP_FIRST_YEAR) return 0;
- /* h-m-s-MM-DD-YY */
+ // h-m-s-MM-DD-YY
return mktime(0,0,0,$rr[2],$rr[3],$rr[1]);
}
($v), $rr)) return false;
if ($rr[1] <= TIMESTAMP_FIRST_YEAR && $rr[2]<= 1) return 0;
- /* h-m-s-MM-DD-YY */
+ // h-m-s-MM-DD-YY
return @mktime($rr[5],$rr[6],$rr[7],$rr[2],$rr[3],$rr[1]);
}
return "'".str_replace("'",$this->replaceQuote,$s)."'";
}
- /* undo magic quotes for " */
+ // undo magic quotes for "
$s = str_replace('\\"','"',$s);
- if ($this->replaceQuote == "\\'") /* ' already quoted, no need to change anything */
+ if ($this->replaceQuote == "\\'") // ' already quoted, no need to change anything
return "'$s'";
- else {/* change \' to '' for sybase/mssql */
+ else {// change \' to '' for sybase/mssql
$s = str_replace('\\\\','\\',$s);
return "'".str_replace("\\'",$this->replaceQuote,$s)."'";
}
return $this->PageExecute($sql,$nrows,$page,$inputarr,$arg3,$secs2cache);
}
-} /* end class ADOConnection */
+} // end class ADOConnection
- /* ============================================================================================== */
- /* CLASS ADOFetchObj */
- /* ============================================================================================== */
+ //==============================================================================================
+ // CLASS ADOFetchObj
+ //==============================================================================================
/**
* Internal placeholder for record objects. Used by ADORecordSet->FetchObj().
class ADOFetchObj {
};
- /* ============================================================================================== */
- /* CLASS ADORecordSet_empty */
- /* ============================================================================================== */
+ //==============================================================================================
+ // CLASS ADORecordSet_empty
+ //==============================================================================================
/**
* Lightweight recordset when there are no records to be returned
function FieldCount(){ return 0;}
}
- /* ============================================================================================== */
- /* CLASS ADORecordSet */
- /* ============================================================================================== */
+ //==============================================================================================
+ // CLASS ADORecordSet
+ //==============================================================================================
/**
* RecordSet class that represents the dataset returned by the database.
* public variables
*/
var $dataProvider = "native";
- var $fields = false; /* holds the current row data */
- var $blobSize = 64; /* any varchar/char field this size or greater is treated as a blob */
- /* in other words, we use a text area for editting. */
- var $canSeek = false; /* indicates that seek is supported */
- var $sql; /* sql text */
+ var $fields = false; // holds the current row data
+ var $blobSize = 64; // any varchar/char field this size or greater is treated as a blob
+ // in other words, we use a text area for editting.
+ var $canSeek = false; // indicates that seek is supported
+ var $sql; // sql text
var $EOF = false; /* Indicates that the current record position is after the last record in a Recordset object. */
- var $emptyTimeStamp = ' '; /* what to display when $time==0 */
- var $emptyDate = ' '; /* what to display when $time==0 */
+ var $emptyTimeStamp = ' '; // what to display when $time==0
+ var $emptyDate = ' '; // what to display when $time==0
var $debug = false;
- var $timeCreated=0; /* datetime in Unix format rs created -- for cached recordsets */
+ var $timeCreated=0; // datetime in Unix format rs created -- for cached recordsets
- var $bind = false; /* used by Fields() to hold array - should be private? */
- var $fetchMode; /* default fetch mode */
- var $connection = false; /* the parent connection */
+ var $bind = false; // used by Fields() to hold array - should be private?
+ var $fetchMode; // default fetch mode
+ var $connection = false; // the parent connection
/*
* private variables
*/
}
}
} else {
- /* return scalar values */
+ // return scalar values
if ($numIndex) {
while (!$this->EOF) {
- /* some bug in mssql PHP 4.02 -- doesn't handle references properly so we FORCE creating a new string */
+ // some bug in mssql PHP 4.02 -- doesn't handle references properly so we FORCE creating a new string
$results[trim(($this->fields[0]))] = $this->fields[1];
$this->MoveNext();
}
} else {
while (!$this->EOF) {
- /* some bug in mssql PHP 4.02 -- doesn't handle references properly so we FORCE creating a new string */
+ // some bug in mssql PHP 4.02 -- doesn't handle references properly so we FORCE creating a new string
$v1 = trim(reset($this->fields));
$v2 = ''.next($this->fields);
$results[$v1] = $v2;
function UserTimeStamp($v,$fmt='Y-m-d H:i:s')
{
$tt = $this->UnixTimeStamp($v);
- /* $tt == -1 if pre TIMESTAMP_FIRST_YEAR */
+ // $tt == -1 if pre TIMESTAMP_FIRST_YEAR
if (($tt === false || $tt == -1) && $v != false) return $v;
if ($tt == 0) return $this->emptyTimeStamp;
function UserDate($v,$fmt='Y-m-d')
{
$tt = $this->UnixDate($v);
- /* $tt == -1 if pre TIMESTAMP_FIRST_YEAR */
+ // $tt == -1 if pre TIMESTAMP_FIRST_YEAR
if (($tt === false || $tt == -1) && $v != false) return $v;
else if ($tt == 0) return $this->emptyDate;
- else if ($tt == -1) { /* pre-TIMESTAMP_FIRST_YEAR */
+ else if ($tt == -1) { // pre-TIMESTAMP_FIRST_YEAR
}
return date($fmt,$tt);
($v), $rr)) return false;
if ($rr[1] <= 1903) return 0;
- /* h-m-s-MM-DD-YY */
+ // h-m-s-MM-DD-YY
return mktime(0,0,0,$rr[2],$rr[3],$rr[1]);
}
($v), $rr)) return false;
if ($rr[1] <= 1903 && $rr[2]<= 1) return 0;
- /* h-m-s-MM-DD-YY */
+ // h-m-s-MM-DD-YY
return @mktime($rr[5],$rr[6],$rr[7],$rr[2],$rr[3],$rr[1]);
}
if ($this->EOF) return (defined('PEAR_ERROR_RETURN')) ? new PEAR_Error('EOF',-1): false;
$arr = $this->fields;
$this->MoveNext();
- return 1; /* DB_OK */
+ return 1; // DB_OK
}
$this->_currentRow = $rowNumber;
if ($this->_fetch()) {
$this->EOF = false;
- /* $this->_currentRow += 1; */
+ // $this->_currentRow += 1;
return true;
}
} else
*/
function Close()
{
- /* free connection object - this seems to globally free the object */
- /* and not merely the reference, so don't do this... */
- /* $this->connection = false; */
+ // free connection object - this seems to globally free the object
+ // and not merely the reference, so don't do this...
+ // $this->connection = false;
if (!$this->_closed) {
$this->_closed = true;
return $this->_close();
function PO_RecordCount($table="", $condition="") {
$lnumrows = $this->_numOfRows;
- /* the database doesn't support native recordcount, so we do a workaround */
+ // the database doesn't support native recordcount, so we do a workaround
if ($lnumrows == -1 && $this->connection) {
IF ($table) {
if ($condition) $condition = " WHERE " . $condition;
*/
function &FetchField($fieldoffset)
{
- /* must be defined by child class */
+ // must be defined by child class
}
/**
if ($status != false) $this->_atLastPage = $status;
return $this->_atLastPage;
}
-} /* end class ADORecordSet */
+} // end class ADORecordSet
- /* ============================================================================================== */
- /* CLASS ADORecordSet_array */
- /* ============================================================================================== */
+ //==============================================================================================
+ // CLASS ADORecordSet_array
+ //==============================================================================================
/**
* This class encapsulates the concept of a recordset created in memory
{
var $databaseType = "array";
- var $_array; /* holds the 2-dimensional data array */
- var $_types; /* the array of types of each column (C B I L M) */
- var $_colnames; /* names of each column in array */
- var $_skiprow1; /* skip 1st row because it holds column names */
- var $_fieldarr; /* holds array of field objects */
+ var $_array; // holds the 2-dimensional data array
+ var $_types; // the array of types of each column (C B I L M)
+ var $_colnames; // names of each column in array
+ var $_skiprow1; // skip 1st row because it holds column names
+ var $_fieldarr; // holds array of field objects
var $canSeek = true;
var $affectedrows = false;
var $insertid = false;
{
global $ADODB_FETCH_MODE;
- $this->ADORecordSet($fakeid); /* fake queryID */
+ $this->ADORecordSet($fakeid); // fake queryID
$this->fetchMode = $ADODB_FETCH_MODE;
}
$o = new ADOFieldObject();
$o->name = $this->_colnames[$fieldOffset];
$o->type = $this->_types[$fieldOffset];
- $o->max_length = -1; /* length not known */
+ $o->max_length = -1; // length not known
return $o;
}
return true;
}
- } /* ADORecordSet_array */
+ } // ADORecordSet_array
- /* ============================================================================================== */
- /* HELPER FUNCTIONS */
- /* ============================================================================================== */
+ //==============================================================================================
+ // HELPER FUNCTIONS
+ //==============================================================================================
/**
* Synonym for ADOLoadCode.
*/
function adodb_write_file($filename, $contents,$debug=false)
{
- # http:/* www.php.net/bugs.php?id=9203 Bug that flock fails on Windows */
+ # http://www.php.net/bugs.php?id=9203 Bug that flock fails on Windows
# So to simulate locking, we assume that rename is an atomic operation.
# First we delete $filename, then we create a $tempfile write to it and
# rename to the desired $filename. If the rename works, then we successfully
# 3. adodb reads stale file because unlink fails -- ok, $rs timeout occurs
# 4. another process creates $filename between unlink() and rename() -- ok, rename() fails and cache updated
if (strpos(strtoupper(PHP_OS),'WIN') !== false) {
- /* skip the decimal place */
+ // skip the decimal place
$mtime = substr(str_replace(' ','_',microtime()),2);
- /* unlink will let some latencies develop, so uniqid() is more random */
+ // unlink will let some latencies develop, so uniqid() is more random
@unlink($filename);
- /* getmypid() actually returns 0 on Win98 - never mind! */
+ // getmypid() actually returns 0 on Win98 - never mind!
$tmpname = $filename.uniqid($mtime).getmypid();
if (!($fd = fopen($tmpname,'a'))) return false;
$ok = ftruncate($fd,0);
return $ok;
}
-} /* defined */
+} // defined
?>
\ No newline at end of file
<?php
-/* Session Encryption by Ari Kuorikoski <ari.kuorikoski@finebyte.com> */
+// Session Encryption by Ari Kuorikoski <ari.kuorikoski@finebyte.com>
class MD5Crypt{
function keyED($txt,$encrypt_key){
$encrypt_key = md5($encrypt_key);
class ADODB_access extends ADODB_odbc {
var $databaseType = 'access';
- var $hasTop = 'top'; /* support mssql SELECT TOP 10 * FROM TABLE */
+ var $hasTop = 'top'; // support mssql SELECT TOP 10 * FROM TABLE
var $fmtDate = "#Y-m-d#";
- var $fmtTimeStamp = "#Y-m-d h:i:sA#"; /* note not comma */
- var $_bindInputArray = false; /* strangely enough, setting to true does not work reliably */
+ var $fmtTimeStamp = "#Y-m-d h:i:sA#"; // note not comma
+ var $_bindInputArray = false; // strangely enough, setting to true does not work reliably
var $sysDate = "FORMAT(NOW,'yyyy-mm-dd')";
var $sysTimeStamp = 'NOW';
return $this->ADORecordSet_odbc($id);
}
}
-} /* class */
+} // class
?>
\ No newline at end of file
var $_bindInputArray = false;
var $fmtDate = "'Y-m-d'";
var $fmtTimeStamp = "'Y-m-d, h:i:sA'";
- var $replaceQuote = "''"; /* string to use to replace quotes */
+ var $replaceQuote = "''"; // string to use to replace quotes
var $dataProvider = "ado";
var $hasAffectedRows = true;
- var $adoParameterType = 201; /* 201 = long varchar, 203=long wide varchar, 205 = long varbinary */
+ var $adoParameterType = 201; // 201 = long varchar, 203=long wide varchar, 205 = long varbinary
var $_affectedRows = false;
var $_thisTransactions;
var $_inTransaction = 0;
- var $_cursor_type = 3; /* 3=adOpenStatic,0=adOpenForwardOnly,1=adOpenKeyset,2=adOpenDynamic */
- var $_cursor_location = 3; /* 2=adUseServer, 3 = adUseClient; */
+ var $_cursor_type = 3; // 3=adOpenStatic,0=adOpenForwardOnly,1=adOpenKeyset,2=adOpenDynamic
+ var $_cursor_location = 3; // 2=adUseServer, 3 = adUseClient;
var $_lock_type = -1;
var $_execute_option = -1;
return $this->_affectedRows;
}
- /* you can also pass a connection string like this: */
- /* */
- /* $DB->Connect('USER ID=sa;PASSWORD=pwd;SERVER=mangrove;DATABASE=ai',false,false,'SQLOLEDB'); */
+ // you can also pass a connection string like this:
+ //
+ // $DB->Connect('USER ID=sa;PASSWORD=pwd;SERVER=mangrove;DATABASE=ai',false,false,'SQLOLEDB');
function _connect($argHostname, $argUsername, $argPassword, $argProvider= 'MSDASQL')
{
$u = 'UID';
/* special support if provider is mssql or access */
if ($argProvider=='mssql') {
- $u = 'User Id'; /* User parameter name for OLEDB */
+ $u = 'User Id'; //User parameter name for OLEDB
$p = 'Password';
- $argProvider = "SQLOLEDB"; /* SQL Server Provider */
+ $argProvider = "SQLOLEDB"; // SQL Server Provider
- /* not yet */
- /* if ($argDatabasename) $argHostname .= ";Initial Catalog=$argDatabasename"; */
+ // not yet
+ //if ($argDatabasename) $argHostname .= ";Initial Catalog=$argDatabasename";
- /* use trusted conection for SQL if username not specified */
+ //use trusted conection for SQL if username not specified
if (!$argUsername) $argHostname .= ";Trusted_Connection=Yes";
} else if ($argProvider=='access')
- $argProvider = "Microsoft.Jet.OLEDB.4.0"; /* Microsoft Jet Provider */
+ $argProvider = "Microsoft.Jet.OLEDB.4.0"; // Microsoft Jet Provider
if ($argProvider) $dbc->Provider = $argProvider;
if ($argPassword)$argHostname .= ";$p=$argPassword";
if ($this->debug) print "<p>Host=".$argHostname."<BR>version=$dbc->version</p>";
- /* @ added below for php 4.0.1 and earlier */
+ // @ added below for php 4.0.1 and earlier
@$dbc->Open((string) $argHostname);
$this->_connectionID = $dbc;
return $dbc->State > 0;
}
- /* returns true or false */
+ // returns true or false
function _pconnect($argHostname, $argUsername, $argPassword, $argProvider='MSDASQL')
{
return $this->_connect($argHostname,$argUsername,$argPassword,$argProvider);
$arr= array();
$dbc = $this->_connectionID;
- $adors=@$dbc->OpenSchema(20);/* tables */
+ $adors=@$dbc->OpenSchema(20);//tables
if ($adors){
- $f = $adors->Fields(2);/* table/view name */
- $t = $adors->Fields(3);/* table type */
+ $f = $adors->Fields(2);//table/view name
+ $t = $adors->Fields(3);//table type
while (!$adors->EOF){
$tt=substr($t->value,0,6);
if ($tt!='SYSTEM' && $tt !='ACCESS')
$arr[]=$f->value;
- /* print $f->value . ' ' . $t->value.'<br>'; */
+ //print $f->value . ' ' . $t->value.'<br>';
$adors->MoveNext();
}
$adors->Close();
$arr= array();
$dbc = $this->_connectionID;
- $adors=@$dbc->OpenSchema(4);/* tables */
+ $adors=@$dbc->OpenSchema(4);//tables
if ($adors){
- $t = $adors->Fields(2);/* table/view name */
+ $t = $adors->Fields(2);//table/view name
while (!$adors->EOF){
$fld = new ADOFieldObject();
$c = $adors->Fields(3);
$fld->name = $c->Value;
- $fld->type = 'CHAR'; /* cannot discover type in ADO! */
+ $fld->type = 'CHAR'; // cannot discover type in ADO!
$fld->max_length = -1;
$arr[strtoupper($fld->name)]=$fld;
}
$dbc = $this->_connectionID;
- /* return rs */
+ // return rs
if ($inputarr) {
$oCmd = new COM('ADODB.Command');
$oCmd->ActiveConnection = $dbc;
$oCmd->CommandType = 1;
foreach($inputarr as $val) {
- /* name, type, direction 1 = input, len, */
+ // name, type, direction 1 = input, len,
$this->adoParameterType = 130;
$p = $oCmd->CreateParameter('name',$this->adoParameterType,1,strlen($val),$val);
- /* print $p->Type.' '.$p->value; */
+ //print $p->Type.' '.$p->value;
$oCmd->Parameters->Append($p);
}
$p = false;
if ($dbc->Errors->Count > 0) return false;
if (! $rs) return false;
- if ($rs->State == 0) return true; /* 0 = adStateClosed means no records returned */
+ if ($rs->State == 0) return true; // 0 = adStateClosed means no records returned
return $rs;
}
return $err->NativeError;
}
- /* returns true or false */
+ // returns true or false
function _close()
{
if ($this->_connectionID) $this->_connectionID->Close();
var $bind = false;
var $databaseType = "ado";
var $dataProvider = "ado";
- var $_tarr = false; /* caches the types */
- var $_flds; /* and field objects */
+ var $_tarr = false; // caches the types
+ var $_flds; // and field objects
var $canSeek = true;
var $hideErrors = true;
}
- /* returns the field object */
+ // returns the field object
function FetchField($fieldOffset = -1) {
- $off=$fieldOffset+1; /* offsets begin at 1 */
+ $off=$fieldOffset+1; // offsets begin at 1
$o= new ADOFieldObject();
$rs = $this->_queryID;
$o->ado_type = $t;
- /* print "off=$off name=$o->name type=$o->type len=$o->max_length<br>"; */
+ //print "off=$off name=$o->name type=$o->type len=$o->max_length<br>";
return $o;
}
}
- /* should only be used to move forward as we normally use forward-only cursors */
+ // should only be used to move forward as we normally use forward-only cursors
function _seek($row)
{
$rs = $this->_queryID;
- /* absoluteposition doesn't work -- my maths is wrong ? */
- /* $rs->AbsolutePosition->$row-2; */
- /* return true; */
+ // absoluteposition doesn't work -- my maths is wrong ?
+ // $rs->AbsolutePosition->$row-2;
+ // return true;
if ($this->_currentRow > $row) return false;
- @$rs->Move((integer)$row - $this->_currentRow-1); /* adBookmarkFirst */
+ @$rs->Move((integer)$row - $this->_currentRow-1); //adBookmarkFirst
return true;
}
switch ($t) {
case 0:
- case 12: /* variant */
- case 8: /* bstr */
- case 129: /* char */
- case 130: /* wc */
- case 200: /* varc */
- case 202:/* varWC */
- case 128: /* bin */
- case 204: /* varBin */
- case 72: /* guid */
+ case 12: // variant
+ case 8: // bstr
+ case 129: //char
+ case 130: //wc
+ case 200: // varc
+ case 202:// varWC
+ case 128: // bin
+ case 204: // varBin
+ case 72: // guid
if ($len <= $this->blobSize) return 'C';
case 201:
case 11: return 'L';
- case 16:/* adTinyInt = 16, */
- case 2:/* adSmallInt = 2, */
- case 3:/* adInteger = 3, */
- case 4:/* adBigInt = 20, */
- case 17:/* adUnsignedTinyInt = 17, */
- case 18:/* adUnsignedSmallInt = 18, */
- case 19:/* adUnsignedInt = 19, */
- case 20:/* adUnsignedBigInt = 21, */
+ case 16:// adTinyInt = 16,
+ case 2://adSmallInt = 2,
+ case 3://adInteger = 3,
+ case 4://adBigInt = 20,
+ case 17://adUnsignedTinyInt = 17,
+ case 18://adUnsignedSmallInt = 18,
+ case 19://adUnsignedInt = 19,
+ case 20://adUnsignedBigInt = 21,
return 'I';
default: return 'N';
}
}
- /* time stamp not supported yet */
+ // time stamp not supported yet
function _fetch()
{
$rs = $this->_queryID;
$flds[] = $f;
$tarr[] = $f->Type;
}
- /* bind types and flds only once */
+ // bind types and flds only once
$this->_tarr = $tarr;
$this->_flds = $flds;
}
$t = reset($this->_tarr);
$f = reset($this->_flds);
- if ($this->hideErrors) $olde = error_reporting(E_ERROR|E_CORE_ERROR);/* sometimes $f->value be null */
+ if ($this->hideErrors) $olde = error_reporting(E_ERROR|E_CORE_ERROR);// sometimes $f->value be null
for ($i=0,$max = $this->_numOfFields; $i < $max; $i++) {
switch($t) {
- case 135: /* timestamp */
+ case 135: // timestamp
$this->fields[] = date('Y-m-d H:i:s',(integer)$f->value);
break;
- case 133:/* A date value (yyyymmdd) */
+ case 133:// A date value (yyyymmdd)
$val = $f->value;
$this->fields[] = substr($val,0,4).'-'.substr($val,4,2).'-'.substr($val,6,2);
break;
- case 7: /* adDate */
+ case 7: // adDate
$this->fields[] = date('Y-m-d',(integer)$f->value);
break;
- case 1: /* null */
+ case 1: // null
$this->fields[] = false;
break;
- case 6: /* currency is not supported properly; */
+ case 6: // currency is not supported properly;
print '<br><b>'.$f->Name.': currency type not supported by PHP</b><br>';
$this->fields[] = (float) $f->value;
break;
$this->fields[] = $f->value;
break;
}
- /* print " $f->value $t, "; */
+ //print " $f->value $t, ";
$f = next($this->_flds);
$t = next($this->_tarr);
- } /* for */
+ } // for
if ($this->hideErrors) error_reporting($olde);
- @$rs->MoveNext(); /* @ needed for some versions of PHP! */
+ @$rs->MoveNext(); // @ needed for some versions of PHP!
if ($this->fetchMode == ADODB_FETCH_ASSOC) {
$this->fields = $this->GetRowAssoc(false);
function _close() {
$this->_flds = false;
- @$this->_queryID->Close();/* by Pete Dishman (peterd@telephonetics.co.uk) */
+ @$this->_queryID->Close();// by Pete Dishman (peterd@telephonetics.co.uk)
$this->_queryID = false;
}
class ADODB_ado_access extends ADODB_ado {
var $databaseType = 'ado_access';
- var $hasTop = 'top'; /* support mssql SELECT TOP 10 * FROM TABLE */
+ var $hasTop = 'top'; // support mssql SELECT TOP 10 * FROM TABLE
var $fmtDate = "#Y-m-d#";
- var $fmtTimeStamp = "#Y-m-d h:i:sA#";/* note no comma */
+ var $fmtTimeStamp = "#Y-m-d h:i:sA#";// note no comma
var $sysDate = "FORMAT(NOW,'yyyy-mm-dd')";
var $sysTimeStamp = 'NOW';
var $hasTop = 'top';
var $sysDate = 'GetDate()';
var $sysTimeStamp = 'GetDate()';
- /* var $_inTransaction = 1; // always open recordsets, so no transaction problems. */
+ //var $_inTransaction = 1; // always open recordsets, so no transaction problems.
function ADODB_ado_mssql()
{
$this->ADODB_ibase();
}
- /* Note that Interbase 6.5 uses ROWS instead - don't you love forking wars! */
- /* SELECT col1, col2 FROM table ROWS 5 -- get 5 rows */
- /* SELECT col1, col2 FROM TABLE ORDER BY col1 ROWS 3 TO 7 -- first 5 skip 2 */
- /* Firebird uses */
- /* SELECT FIRST 5 SKIP 2 col1, col2 FROM TABLE */
+ // Note that Interbase 6.5 uses ROWS instead - don't you love forking wars!
+ // SELECT col1, col2 FROM table ROWS 5 -- get 5 rows
+ // SELECT col1, col2 FROM TABLE ORDER BY col1 ROWS 3 TO 7 -- first 5 skip 2
+ // Firebird uses
+ // SELECT FIRST 5 SKIP 2 col1, col2 FROM TABLE
function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false, $arg3=false,$secs=0)
{
if ($nrows > 0) {
$str = " ROWS $a TO $b";
}
} else {
- /* ok, skip */
+ // ok, skip
$a = $offset + 1;
- $str = " ROWS $a TO 999999999"; /* 999 million */
+ $str = " ROWS $a TO 999999999"; // 999 million
}
$sql .= $str;
var $_affectedrows=0;
var $_insertid=0;
var $_url;
- var $replaceQuote = "''"; /* string to use to replace quotes */
+ var $replaceQuote = "''"; // string to use to replace quotes
function ADODB_csv()
{
}
- /* returns true or false */
+ // returns true or false
function _connect($argHostname, $argUsername, $argPassword, $argDatabasename)
{
- if (strtolower(substr($argHostname,0,7)) !== 'http:/* ') return false; */
+ if (strtolower(substr($argHostname,0,7)) !== 'http://') return false;
$this->_url = $argHostname;
return true;
}
- /* returns true or false */
+ // returns true or false
function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
{
- if (strtolower(substr($argHostname,0,7)) !== 'http:/* ') return false; */
+ if (strtolower(substr($argHostname,0,7)) !== 'http://') return false;
$this->_url = $argHostname;
return true;
}
}
- /* parameters use PostgreSQL convention, not MySQL */
+ // parameters use PostgreSQL convention, not MySQL
function &SelectLimit($sql,$nrows=-1,$offset=-1,$arg3=false)
{
global $ADODB_FETCH_MODE;
return $rs;
}
- /* returns queryID or false */
+ // returns queryID or false
function &Execute($sql,$inputarr=false,$arg3=false)
{
global $ADODB_FETCH_MODE;
foreach($inputarr as $v) {
$sql .= $sqlarr[$i];
- /* from Ron Baldwin <ron.baldwin@sourceprose.com> */
- /* Only quote string types */
+ // from Ron Baldwin <ron.baldwin@sourceprose.com>
+ // Only quote string types
if (gettype($v) == 'string')
$sql .= $this->qstr($v);
else if ($v === null)
return $this->_errorNo;
}
- /* returns true or false */
+ // returns true or false
function _close()
{
return true;
}
-} /* class */
+} // class
class ADORecordset_csv extends ADORecordset {
function ADORecordset_csv($id)
}
}
-} /* define */
+} // define
?>
\ No newline at end of file
var $concat_operator = 'CONCAT';
var $sysDate = 'CURRENT DATE';
var $sysTimeStamp = 'CURRENT TIMESTAMP';
- /* var $curmode = SQL_CUR_USE_ODBC; */
+ //var $curmode = SQL_CUR_USE_ODBC;
function ADODB_DB2()
{
$this->ADODB_odbc();
}
- /* returns true or false */
- /* curmode is not properly supported by DB2 odbc driver according to Mark Newnham */
+ // returns true or false
+ // curmode is not properly supported by DB2 odbc driver according to Mark Newnham
function _connect($argDSN, $argUsername, $argPassword, $argDatabasename)
{
global $php_errormsg;
$this->_connectionID = odbc_connect($argDSN,$argUsername,$argPassword);
$this->_errorMsg = $php_errormsg;
- /* if ($this->_connectionID) odbc_autocommit($this->_connectionID,true); */
+ //if ($this->_connectionID) odbc_autocommit($this->_connectionID,true);
return $this->_connectionID != false;
}
- /* returns true or false */
+ // returns true or false
function _pconnect($argDSN, $argUsername, $argPassword, $argDatabasename)
{
global $php_errormsg;
$this->_connectionID = odbc_pconnect($argDSN,$argUsername,$argPassword);
$this->_errorMsg = $php_errormsg;
- /* if ($this->_connectionID) odbc_autocommit($this->_connectionID,true); */
+ //if ($this->_connectionID) odbc_autocommit($this->_connectionID,true);
return $this->_connectionID != false;
}
function &SelectLimit($sql,$nrows=-1,$offset=-1,$arg3=false)
{
if ($offset <= 0) {
- /* could also use " OPTIMIZE FOR $nrows ROWS " */
+ // could also use " OPTIMIZE FOR $nrows ROWS "
$sql .= " FETCH FIRST $nrows ROWS ONLY ";
return $this->Execute($sql,false,$arg3);
} else {
case 'LONGCHAR':
case 'TEXT':
case 'CLOB':
- case 'DBCLOB': /* double-byte */
+ case 'DBCLOB': // double-byte
return 'X';
case 'BLOB':
case 'TIMESTAMP':
return 'T';
- /* case 'BOOLEAN': */
- /* case 'BIT': */
- /* return 'L'; */
+ //case 'BOOLEAN':
+ //case 'BIT':
+ // return 'L';
- /* case 'COUNTER': */
- /* return 'R'; */
+ //case 'COUNTER':
+ // return 'R';
case 'INT':
case 'INTEGER':
}
}
-} /* define */
+} //define
?>
\ No newline at end of file
return $arr;
}
- /* returns concatenated string */
+ // returns concatenated string
function Concat()
{
$s = "";
else return '';
}
- /* returns true or false */
+ // returns true or false
function _connect($argHostname, $argUsername, $argPassword, $argDatabasename)
{
$this->_connectionID = fbsql_connect($argHostname,$argUsername,$argPassword);
return true;
}
- /* returns true or false */
+ // returns true or false
function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
{
$this->_connectionID = fbsql_pconnect($argHostname,$argUsername,$argPassword);
$fld->name = $rs->fields[0];
$fld->type = $rs->fields[1];
- /* split type into type(length): */
+ // split type into type(length):
if (preg_match("/^(.+)\((\d+)\)$/", $fld->type, $query_array)) {
$fld->type = $query_array[1];
$fld->max_length = $query_array[2];
return false;
}
- /* returns true or false */
+ // returns true or false
function SelectDB($dbName)
{
$this->databaseName = $dbName;
}
- /* returns queryID or false */
+ // returns queryID or false
function _query($sql,$inputarr)
{
return fbsql_query("$sql;",$this->_connectionID);
return @fbsql_errno($this->_connectionID);
}
- /* returns true or false */
+ // returns true or false
function _close()
{
return @fbsql_close($this->_connectionID);
function &FetchField($fieldOffset = -1) {
if ($fieldOffset != -1) {
$o = @fbsql_fetch_field($this->_queryID, $fieldOffset);
- /* $o->max_length = -1; // fbsql returns the max length less spaces -- so it is unrealiable */
+ //$o->max_length = -1; // fbsql returns the max length less spaces -- so it is unrealiable
$f = @fbsql_field_flags($this->_queryID,$fieldOffset);
$o->binary = (strpos($f,'binary')!== false);
}
else if ($fieldOffset == -1) { /* The $fieldOffset argument is not provided thus its -1 */
- $o = @fbsql_fetch_field($this->_queryID);/* fbsql returns the max length less spaces -- so it is unrealiable */
- /* $o->max_length = -1; */
+ $o = @fbsql_fetch_field($this->_queryID);// fbsql returns the max length less spaces -- so it is unrealiable
+ //$o->max_length = -1;
}
return $o;
function MetaType($t,$len=-1,$fieldobj=false)
{
- $len = -1; /* fbsql max_length is not accurate */
+ $len = -1; // fbsql max_length is not accurate
switch (strtoupper($t)) {
case 'CHARACTER':
case 'CHARACTER VARYING':
case 'BIT VARYING':
if ($len <= $this->blobSize) return 'C';
- /* so we have to check whether binary... */
+ // so we have to check whether binary...
case 'IMAGE':
case 'LONGBLOB':
case 'BLOB':
}
}
-} /* class */
-} /* defined */
+} //class
+} // defined
?>
\ No newline at end of file
$this->ADODB_ibase();
}
- /* Note that Interbase 6.5 uses this ROWS instead - don't you love forking wars! */
- /* SELECT col1, col2 FROM table ROWS 5 -- get 5 rows */
- /* SELECT col1, col2 FROM TABLE ORDER BY col1 ROWS 3 TO 7 -- first 5 skip 2 */
+ // Note that Interbase 6.5 uses this ROWS instead - don't you love forking wars!
+ // SELECT col1, col2 FROM table ROWS 5 -- get 5 rows
+ // SELECT col1, col2 FROM TABLE ORDER BY col1 ROWS 3 TO 7 -- first 5 skip 2
function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false, $arg3=false,$secs=0)
{
$str = 'SELECT ';
class ADODB_ibase extends ADOConnection {
var $databaseType = "ibase";
- var $replaceQuote = "\'"; /* string to use to replace quotes */
+ var $replaceQuote = "\'"; // string to use to replace quotes
var $fmtDate = "'Y-m-d'";
var $fmtTimeStamp = "'Y-m-d, H:i:s'";
var $concat_operator='||';
function BeginTrans()
{
$this->autoCommit = false;
- $this->_transactionID = $this->_connectionID;/* ibase_trans($this->ibasetrans, $this->_connectionID); */
+ $this->_transactionID = $this->_connectionID;//ibase_trans($this->ibasetrans, $this->_connectionID);
return $this->_transactionID;
}
$ret = false;
$this->autoCommit = true;
if ($this->_transactionID) {
- /* print ' commit '; */
+ //print ' commit ';
$ret = ibase_commit($this->_transactionID);
}
$this->_transactionID = false;
return $ret;
}
- /* See http://community.borland.com/article/0,1410,25844,00.html */
+ // See http://community.borland.com/article/0,1410,25844,00.html
function RowLock($tables,$where,$col)
{
if ($this->autoCommit) $this->BeginTrans();
- $this->Execute("UPDATE $table SET $col=$col WHERE $where "); /* is this correct - jlim? */
+ $this->Execute("UPDATE $table SET $col=$col WHERE $where "); // is this correct - jlim?
return 1;
}
$rs = $this->Execute($getnext);
}
if ($rs && !$rs->EOF) $this->genID = (integer) reset($rs->fields);
- else $this->genID = 0; /* false */
+ else $this->genID = 0; // false
if ($rs) $rs->Close();
return $this->_errorMsg;
}
- /* returns true or false */
+ // returns true or false
function _connect($argHostname, $argUsername, $argPassword, $argDatabasename)
{
- /* if ($this->charSet !== false) */
+ //if ($this->charSet !== false)
$this->_connectionID = ibase_connect($argHostname,$argUsername,$argPassword,$this->charSet,$this->buffers,$this->dialect);
- /* else */
- /* $this->_connectionID = ibase_connect($argHostname,$argUsername,$argPassword); */
+ // else
+ // $this->_connectionID = ibase_connect($argHostname,$argUsername,$argPassword);
if ($this->_connectionID === false) {
$this->_handleerror();
return true;
}
- /* returns true or false */
+ // returns true or false
function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
{
- /* if ($this->charSet !== false) */
+ //if ($this->charSet !== false)
$this->_connectionID = ibase_pconnect($argHostname,$argUsername,$argPassword,$this->charSet,$this->buffers,$this->dialect);
- /* else */
- /* $this->_connectionID = ibase_pconnect($argHostname,$argUsername,$argPassword); */
+ // else
+ // $this->_connectionID = ibase_pconnect($argHostname,$argUsername,$argPassword);
if ($this->_connectionID === false) {
$this->_handleerror();
return array($sql,$stmt);
}
- /* returns query ID if successful, otherwise false */
- /* there have been reports of problems with nested queries - the code is probably not re-entrant? */
+ // returns query ID if successful, otherwise false
+ // there have been reports of problems with nested queries - the code is probably not re-entrant?
function _query($sql,$iarr=false)
{
if (is_array($sql)) {
return $ret;
}
- /* returns true or false */
+ // returns true or false
function _close()
{
if (!$this->autoCommit) @ibase_rollback($this->_connectionID);
return @ibase_close($this->_connectionID);
}
- /* returns array of ADOFieldObjects for current table */
+ // returns array of ADOFieldObjects for current table
function &MetaColumns($table)
{
global $ADODB_FETCH_MODE;
if ($rs === false) return false;
$retarr = array();
- while (!$rs->EOF) { /* print_r($rs->fields); */
+ while (!$rs->EOF) { //print_r($rs->fields);
$fld = new ADOFieldObject();
$fld->name = $rs->fields[0];
$tt = $rs->fields[1];
return false;
}
- /* no longer needed in php 4.1.0, but still backward compatible */
+ // no longer needed in php 4.1.0, but still backward compatible
function &BlobEncode( $blob )
{
$blobid = ibase_blob_create( $this->_connectionID);
return ibase_blob_close( $blobid );
}
- /* no longer needed in php 4.1.0, but still backward compatible */
+ // no longer needed in php 4.1.0, but still backward compatible
function &BlobDecode( $blob )
{
$blobid = ibase_blob_open( $blob );
- $realblob = ibase_blob_get( $blobid,MAX_BLOB_SIZE); /* 2nd param is max size of blob -- Kevin Boillet <kevinboillet@yahoo.fr> */
+ $realblob = ibase_blob_get( $blobid,MAX_BLOB_SIZE); // 2nd param is max size of blob -- Kevin Boillet <kevinboillet@yahoo.fr>
ibase_blob_close( $blobid );
return( $realblob );
case 'TIMESTAMP':
case 'DATE': return 'D';
- /* case 'T': return 'T'; */
+ //case 'T': return 'T';
- /* case 'L': return 'L'; */
+ //case 'L': return 'L';
case 'INT':
case 'SHORT':
case 'INTEGER': return 'I';
class ADODB_informix72 extends ADOConnection {
var $databaseType = "informix72";
var $dataProvider = "informix";
- var $replaceQuote = "''"; /* string to use to replace quotes */
+ var $replaceQuote = "''"; // string to use to replace quotes
var $fmtDate = "'Y-m-d'";
var $fmtTimeStamp = "'Y-m-d H:i:s'";
var $hasInsertID = true;
var $has_insertid = true;
var $_autocommit = true;
- var $_bindInputArray = true; /* set to true if ADOConnection.Execute() permits binding of array parameters. */
+ var $_bindInputArray = true; // set to true if ADOConnection.Execute() permits binding of array parameters.
var $sysDate = 'TODAY';
var $sysTimeStamp = 'CURRENT';
function ADODB_informix72()
{
- /* alternatively, use older method: */
- /* putenv("DBDATE=Y4MD-"); */
+ // alternatively, use older method:
+ //putenv("DBDATE=Y4MD-");
- /* force ISO date format */
+ // force ISO date format
putenv('GL_DATE=%Y-%m-%d');
}
}
- /* returns true or false */
+ // returns true or false
function _connect($argHostname, $argUsername, $argPassword, $argDatabasename)
{
$dbs = $argDatabasename . "@" . $argHostname;
return true;
}
- /* returns true or false */
+ // returns true or false
function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
{
$dbs = $argDatabasename . "@" . $argHostname;
else return array($sql,$stmt);
}
*/
- /* returns query ID if successful, otherwise false */
+ // returns query ID if successful, otherwise false
function _query($sql,$inputarr)
{
global $ADODB_COUNTRECS;
- /* String parameters have to be converted using ifx_create_char */
+ // String parameters have to be converted using ifx_create_char
if ($inputarr) {
foreach($inputarr as $v) {
if (gettype($v) == 'string') {
}
}
- /* In case of select statement, we use a scroll cursor in order */
- /* to be able to call "move", or "movefirst" statements */
+ // In case of select statement, we use a scroll cursor in order
+ // to be able to call "move", or "movefirst" statements
if ($ADODB_COUNTRECS && preg_match("/^[\\t\\n ]*select/i", $sql)) {
if ($inputarr) {
$this->lastQuery = ifx_query($sql,$this->_connectionID, IFX_SCROLL, $tab);
}
}
- /* Following line have been commented because autocommit mode is */
- /* not supported by informix SE 7.2 */
+ // Following line have been commented because autocommit mode is
+ // not supported by informix SE 7.2
- /* if ($this->_autocommit) ifx_query('COMMIT',$this->_connectionID); */
+ //if ($this->_autocommit) ifx_query('COMMIT',$this->_connectionID);
return $this->lastQuery;
}
- /* returns true or false */
+ // returns true or false
function _close()
{
$this->lastQuery = false;
foreach($fp as $k => $v) {
$o = new ADOFieldObject;
$o->name = $k;
- $arr = split(';',$v); /* "SQLTYPE;length;precision;scale;ISNULLABLE" */
+ $arr = split(';',$v); //"SQLTYPE;length;precision;scale;ISNULLABLE"
$o->type = $arr[0];
$o->max_length = $arr[1];
$this->_fieldprops[] = $o;
function _initrs()
{
- $this->_numOfRows = -1; /* ifx_affected_rows not reliable, only returns estimate -- ($ADODB_COUNTRECS)? ifx_affected_rows($this->_queryID):-1; */
+ $this->_numOfRows = -1; // ifx_affected_rows not reliable, only returns estimate -- ($ADODB_COUNTRECS)? ifx_affected_rows($this->_queryID):-1;
$this->_numOfFields = ifx_num_fields($this->_queryID);
}
*/
-/* ---------------------------------------------------------------- */
-/* MSSQL returns dates with the format Oct 13 2002 or 13 Oct 2002 */
-/* and this causes tons of problems because localized versions of */
-/* MSSQL will return the dates in dmy or mdy order; and also the */
-/* month strings depends on what language has been configured. The */
-/* following two variables allow you to control the localization */
-/* settings - Ugh. */
-/* */
-/* MORE LOCALIZATION INFO */
-/* ---------------------- */
-/* To configure datetime, look for and modify sqlcommn.loc, */
-/* typically found in c:\mssql\install */
-/* Also read : */
-/* http://support.microsoft.com/default.aspx?scid=kb;EN-US;q220918 */
-/* Alternatively use: */
-/* CONVERT(char(12),datecol,120) */
-/* ---------------------------------------------------------------- */
+//----------------------------------------------------------------
+// MSSQL returns dates with the format Oct 13 2002 or 13 Oct 2002
+// and this causes tons of problems because localized versions of
+// MSSQL will return the dates in dmy or mdy order; and also the
+// month strings depends on what language has been configured. The
+// following two variables allow you to control the localization
+// settings - Ugh.
+//
+// MORE LOCALIZATION INFO
+// ----------------------
+// To configure datetime, look for and modify sqlcommn.loc,
+// typically found in c:\mssql\install
+// Also read :
+// http://support.microsoft.com/default.aspx?scid=kb;EN-US;q220918
+// Alternatively use:
+// CONVERT(char(12),datecol,120)
+//----------------------------------------------------------------
-global $ADODB_mssql_date_order; /* 'dmy' and 'mdy' supported */
+global $ADODB_mssql_date_order; // 'dmy' and 'mdy' supported
$ADODB_mssql_has_datetimeconvert = (strnatcmp(PHP_VERSION,'4.2.0')>=0);
if ($ADODB_mssql_has_datetimeconvert) {
ini_set('mssql.datetimeconvert',0);
} else {
-global $ADODB_mssql_mths; /* array, months must be upper-case */
+global $ADODB_mssql_mths; // array, months must be upper-case
global $ADODB_mssql_has_datetimeconvert;
$ADODB_mssql_date_order = 'mdy';
'JAN'=>1,'FEB'=>2,'MAR'=>3,'APR'=>4,'MAY'=>5,'JUN'=>6,
'JUL'=>7,'AUG'=>8,'SEP'=>9,'OCT'=>10,'NOV'=>11,'DEC'=>12);
}
-/* --------------------------------------------------------------------------- */
-/* Call this to autoset $ADODB_mssql_date_order at the beginning of your code, */
-/* just after you connect to the database. Supports mdy and dmy only */
+//---------------------------------------------------------------------------
+// Call this to autoset $ADODB_mssql_date_order at the beginning of your code,
+// just after you connect to the database. Supports mdy and dmy only
function AutoDetect_MSSQL_Date_Order($conn)
{
global $ADODB_mssql_date_order;
class ADODB_mssql extends ADOConnection {
var $databaseType = "mssql";
- var $replaceQuote = "''"; /* string to use to replace quotes */
+ var $replaceQuote = "''"; // string to use to replace quotes
var $fmtDate = "'Y-m-d'";
var $fmtTimeStamp = "'Y-m-d h:i:sA'";
var $hasInsertID = true;
var $hasAffectedRows = true;
var $metaTablesSQL="select name from sysobjects where type='U' or type='V' and (name not in ('sysallocations','syscolumns','syscomments','sysdepends','sysfilegroups','sysfiles','sysfiles1','sysforeignkeys','sysfulltextcatalogs','sysindexes','sysindexkeys','sysmembers','sysobjects','syspermissions','sysprotects','sysreferences','systypes','sysusers','sysalternates','sysconstraints','syssegments','REFERENTIAL_CONSTRAINTS','CHECK_CONSTRAINTS','CONSTRAINT_TABLE_USAGE','CONSTRAINT_COLUMN_USAGE','VIEWS','VIEW_TABLE_USAGE','VIEW_COLUMN_USAGE','SCHEMATA','TABLES','TABLE_CONSTRAINTS','TABLE_PRIVILEGES','COLUMNS','COLUMN_DOMAIN_USAGE','COLUMN_PRIVILEGES','DOMAINS','DOMAIN_CONSTRAINTS','KEY_COLUMN_USAGE'))";
var $metaColumnsSQL = "select c.name,t.name,c.length from syscolumns c join systypes t on t.xusertype=c.xusertype join sysobjects o on o.id=c.id where o.name='%s'";
- var $hasTop = 'top'; /* support mssql SELECT TOP 10 * FROM TABLE */
+ var $hasTop = 'top'; // support mssql SELECT TOP 10 * FROM TABLE
var $_hastrans = false;
var $hasGenID = true;
var $sysDate = 'GetDate()';
$this->_has_mssql_init = (strnatcmp(PHP_VERSION,'4.1.0')>=0);
}
- /* might require begintrans -- committrans */
+ // might require begintrans -- committrans
function _insertid()
{
return $this->GetOne('select @@identity');
}
- /* might require begintrans -- committrans */
+ // might require begintrans -- committrans
function _affectedrows()
{
return $this->GetOne('select @@rowcount');
function GenID($seq='adodbseq',$start=1)
{
- /* $this->debug=1; */
+ //$this->debug=1;
$this->Execute('BEGIN TRANSACTION adodbseq');
$ok = $this->Execute("update $seq with (tablock,holdlock) set id = id + 1");
if (!$ok) {
$this->Execute('COMMIT TRANSACTION adodbseq');
return $num;
- /* in old implementation, pre 1.90, we returned GUID... */
- /* return $this->GetOne("SELECT CONVERT(varchar(255), NEWID()) AS 'Char'"); */
+ // in old implementation, pre 1.90, we returned GUID...
+ //return $this->GetOne("SELECT CONVERT(varchar(255), NEWID()) AS 'Char'");
}
function CommitTrans($ok=true)
return $this->GetOne("select top 1 null as ignore from $tables with (ROWLOCK,HOLDLOCK) where $where");
}
- /* From: Fernando Moreira <FMoreira@imediata.pt> */
+ //From: Fernando Moreira <FMoreira@imediata.pt>
function MetaDatabases()
{
if(@mssql_select_db("master")) {
else return -1;
}
- /* returns true or false */
+ // returns true or false
function _connect($argHostname, $argUsername, $argPassword, $argDatabasename)
{
$this->_connectionID = mssql_connect($argHostname,$argUsername,$argPassword);
}
- /* returns true or false */
+ // returns true or false
function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
{
$this->_connectionID = mssql_pconnect($argHostname,$argUsername,$argPassword);
return $sql;
}
- $isNull = is_null($var); /* php 4.0.4 and above... */
+ $isNull = is_null($var); // php 4.0.4 and above...
if ($type === false)
switch(gettype($var)) {
return $this->Execute($sql) != false;
}
- /* returns query ID if successful, otherwise false */
+ // returns query ID if successful, otherwise false
function _query($sql,$inputarr)
{
$this->_errorMsg = false;
return mssql_query($sql,$this->_connectionID);
}
- /* returns true or false */
+ // returns true or false
function _close()
{
if ($this->_hastrans) $this->RollbackTrans();
return $rez;
}
- /* mssql uses a default date like Dec 30 2000 12:00AM */
+ // mssql uses a default date like Dec 30 2000 12:00AM
function UnixDate($v)
{
return ADORecordSet_array_mssql::UnixDate($v);
var $databaseType = "mssql";
var $canSeek = true;
- /* _mths works only in non-localised system */
+ // _mths works only in non-localised system
function ADORecordset_mssql($id)
{
return $this->ADORecordSet($id);
}
- /* Contributed by "Sven Axelsson" <sven.axelsson@bokochwebb.se> */
- /* get next resultset - requires PHP 4.0.5 or later */
+ //Contributed by "Sven Axelsson" <sven.axelsson@bokochwebb.se>
+ // get next resultset - requires PHP 4.0.5 or later
function NextRecordSet()
{
if (!mssql_next_result($this->_queryID)) return false;
return @mssql_data_seek($this->_queryID, $row);
}
- /* speedup */
+ // speedup
function MoveNext()
{
if (!$this->EOF) {
return false;
}
- /* INSERT UPDATE DELETE returns false even if no error occurs in 4.0.4 */
- /* also the date format has been changed from YYYY-mm-dd to dd MMM YYYY in 4.0.4. Idiot! */
+ // INSERT UPDATE DELETE returns false even if no error occurs in 4.0.4
+ // also the date format has been changed from YYYY-mm-dd to dd MMM YYYY in 4.0.4. Idiot!
function _fetch($ignore_fields=false)
{
if ($this->fetchMode & ADODB_FETCH_ASSOC) $this->fields = @mssql_fetch_array($this->_queryID);
$this->_queryID = false;
return $rez;
}
- /* mssql uses a default date like Dec 30 2000 12:00AM */
+ // mssql uses a default date like Dec 30 2000 12:00AM
function UnixDate($v)
{
return ADORecordSet_array_mssql::UnixDate($v);
$this->ADORecordSet_array($id);
}
- /* mssql uses a default date like Dec 30 2000 12:00AM */
+ // mssql uses a default date like Dec 30 2000 12:00AM
function UnixDate($v)
{
global $ADODB_mssql_has_datetimeconvert;
global $ADODB_mssql_mths,$ADODB_mssql_date_order;
- /* Dec 30 2000 12:00AM */
+ //Dec 30 2000 12:00AM
if ($ADODB_mssql_date_order == 'dmy') {
if (!preg_match( "|^([0-9]{1,2})[-/\. ]+([A-Za-z]{3})[-/\. ]+([0-9]{4})|" ,$v, $rr)) {
return parent::UnixDate($v);
}
$themth = $ADODB_mssql_mths[$themth];
if ($themth <= 0) return false;
- /* h-m-s-MM-DD-YY */
+ // h-m-s-MM-DD-YY
return mktime(0,0,0,$themth,$theday,$rr[3]);
}
global $ADODB_mssql_mths,$ADODB_mssql_date_order;
- /* Dec 30 2000 12:00AM */
+ //Dec 30 2000 12:00AM
if ($ADODB_mssql_date_order == 'dmy') {
if (!preg_match( "|^([0-9]{1,2})[-/\. ]+([A-Za-z]{3})[-/\. ]+([0-9]{4}) +([0-9]{1,2}):([0-9]{1,2}) *([apAP]{0,1})|"
,$v, $rr)) return parent::UnixTimeStamp($v);
default:
break;
}
- /* h-m-s-MM-DD-YY */
+ // h-m-s-MM-DD-YY
return mktime($rr[4],$rr[5],0,$themth,$theday,$rr[3]);
}
}
var $hasMoveFirst = true;
var $hasGenID = true;
var $upperCase = 'upper';
- var $isoDates = true; /* accepts dates in ISO format */
+ var $isoDates = true; // accepts dates in ISO format
var $sysDate = 'CURDATE()';
var $sysTimeStamp = 'NOW()';
var $forceNewConnect = false;
return mysql_affected_rows($this->_connectionID);
}
- /* See http://www.mysql.com/doc/M/i/Miscellaneous_functions.html */
- /* Reference on Last_Insert_ID on the recommended way to simulate sequences */
+ // See http://www.mysql.com/doc/M/i/Miscellaneous_functions.html
+ // Reference on Last_Insert_ID on the recommended way to simulate sequences
var $_genIDSQL = "update %s set id=LAST_INSERT_ID(id+1);";
var $_genSeqSQL = "create table %s (id int not null)";
var $_genSeq2SQL = "insert into %s values (%s)";
function GenID($seqname='adodbseq',$startID=1)
{
- /* if (!$this->hasGenID) return false; */
+ //if (!$this->hasGenID) return false;
$getnext = sprintf($this->_genIDSQL,$seqname);
$rs = @$this->Execute($getnext);
if (!$rs) {
return $arr;
}
- /* returns concatenated string */
+ // returns concatenated string
function Concat()
{
$s = "";
} else $s .= ','.$a;
}*/
- /* suggestion by andrew005@mnogo.ru */
+ // suggestion by andrew005@mnogo.ru
$s = implode(',',$arr);
if (strlen($s) > 0) return "CONCAT($s)";
else return '';
}
- /* returns true or false */
+ // returns true or false
function _connect($argHostname, $argUsername, $argPassword, $argDatabasename)
{
if ($this->forceNewConnect && (strnatcmp(PHP_VERSION,'4.2.0')>=0))
return true;
}
- /* returns true or false */
+ // returns true or false
function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
{
$this->_connectionID = mysql_pconnect($argHostname,$argUsername,$argPassword);
$fld->name = $rs->fields[0];
$fld->type = $rs->fields[1];
- /* split type into type(length): */
+ // split type into type(length):
if (preg_match("/^(.+)\((\d+)\)$/", $fld->type, $query_array)) {
$fld->type = $query_array[1];
$fld->max_length = $query_array[2];
return false;
}
- /* returns true or false */
+ // returns true or false
function SelectDB($dbName)
{
$this->databaseName = $dbName;
else return false;
}
- /* parameters use PostgreSQL convention, not MySQL */
+ // parameters use PostgreSQL convention, not MySQL
function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false, $arg3=false,$secs=0)
{
$offsetStr =($offset>=0) ? "$offset," : '';
}
- /* returns queryID or false */
+ // returns queryID or false
function _query($sql,$inputarr)
{
global $ADODB_COUNTRECS;
if($ADODB_COUNTRECS) return mysql_query($sql,$this->_connectionID);
- else return mysql_unbuffered_query($sql,$this->_connectionID); /* requires PHP >= 4.0.6 */
+ else return mysql_unbuffered_query($sql,$this->_connectionID); // requires PHP >= 4.0.6
}
/* Returns: the last error message from previous database operation */
- /* returns true or false */
+ // returns true or false
function _close()
{
@mysql_close($this->_connectionID);
case 'T': return 'DATETIME';
case 'L': return 'TINYINT';
case 'R': return 'INTEGER NOT NULL AUTO_INCREMENT';
- case 'I': return 'INTEGER'; /* enough for 9 petabytes! */
+ case 'I': return 'INTEGER'; // enough for 9 petabytes!
case 'F': return 'DOUBLE';
case 'N': return 'NUMERIC';
if ($fieldOffset != -1) {
$o = mysql_fetch_field($this->_queryID, $fieldOffset);
$f = @mysql_field_flags($this->_queryID,$fieldOffset);
- $o->max_length = @mysql_field_len($this->_queryID,$fieldOffset); /* suggested by: Jim Nicholson (jnich@att.com) */
- /* $o->max_length = -1; // mysql returns the max length less spaces -- so it is unrealiable */
+ $o->max_length = @mysql_field_len($this->_queryID,$fieldOffset); // suggested by: Jim Nicholson (jnich@att.com)
+ //$o->max_length = -1; // mysql returns the max length less spaces -- so it is unrealiable
$o->binary = (strpos($f,'binary')!== false);
}
else if ($fieldOffset == -1) { /* The $fieldOffset argument is not provided thus its -1 */
$o = @mysql_fetch_field($this->_queryID);
- $o->max_length = @mysql_field_len($this->_queryID); /* suggested by: Jim Nicholson (jnich@att.com) */
- /* $o->max_length = -1; // mysql returns the max length less spaces -- so it is unrealiable */
+ $o->max_length = @mysql_field_len($this->_queryID); // suggested by: Jim Nicholson (jnich@att.com)
+ //$o->max_length = -1; // mysql returns the max length less spaces -- so it is unrealiable
}
return $o;
/* Use associative array to get fields array */
function Fields($colname)
{
- /* added @ by "Michael William Miller" <mille562@pilot.msu.edu> */
+ // added @ by "Michael William Miller" <mille562@pilot.msu.edu>
if ($this->fetchMode != MYSQL_NUM) return @$this->fields[$colname];
if (!$this->bind) {
return false;
} */
- /* 10% speedup to move MoveNext to child class */
+ // 10% speedup to move MoveNext to child class
function MoveNext()
{
if (!$this->EOF) {
$this->_currentRow++;
- /* using & below slows things down by 20%! */
+ // using & below slows things down by 20%!
$this->fields = @mysql_fetch_array($this->_queryID,$this->fetchMode);
if (is_array($this->fields)) return true;
function MetaType($t,$len=-1,$fieldobj=false)
{
- $len = -1; /* mysql max_length is not accurate */
+ $len = -1; // mysql max_length is not accurate
switch (strtoupper($t)) {
case 'STRING':
case 'CHAR':
case 'MEDIUMTEXT':
return 'X';
- /* php_mysql extension always returns 'blob' even if 'text' */
- /* so we have to check whether binary... */
+ // php_mysql extension always returns 'blob' even if 'text'
+ // so we have to check whether binary...
case 'IMAGE':
case 'LONGBLOB':
case 'BLOB':
class ADODB_oci8 extends ADOConnection {
var $databaseType = 'oci8';
var $dataProvider = 'oci8';
- var $replaceQuote = "''"; /* string to use to replace quotes */
+ var $replaceQuote = "''"; // string to use to replace quotes
var $concat_operator='||';
var $sysDate = "TRUNC(SYSDATE)";
var $sysTimeStamp = 'SYSDATE';
var $_stmt;
var $_commit = OCI_COMMIT_ON_SUCCESS;
- var $_initdate = true; /* init date to YYYY-MM-DD */
+ var $_initdate = true; // init date to YYYY-MM-DD
var $metaTablesSQL = "select table_name from cat where table_type in ('TABLE','VIEW')";
var $metaColumnsSQL = "select cname,coltype,width from col where tname='%s' order by colno";
var $_bindInputArray = true;
var $connectSID = false;
var $_bind = false;
var $_hasOCIFetchStatement = false;
- var $_getarray = false; /* currently not working */
+ var $_getarray = false; // currently not working
function ADODB_oci8()
{
return OCIRowCount($this->_stmt);
}
- /* format and return date string in database date format */
+ // format and return date string in database date format
function DBDate($d)
{
if (empty($d) && $d !== 0) return 'null';
return 'TO_DATE('.date($this->fmtDate,$d).",'YYYY-MM-DD')";
}
- /* format and return date string in database timestamp format */
+ // format and return date string in database timestamp format
function DBTimeStamp($ts)
{
if (empty($ts) && $ts !== 0) return 'null';
)
)
*/
- /* returns true or false */
+ // returns true or false
function _connect($argHostname, $argUsername, $argPassword, $argDatabasename,$persist=false)
{
- if($argHostname) { /* added by Jorma Tuomainen <jorma.tuomainen@ppoy.fi> */
+ if($argHostname) { // added by Jorma Tuomainen <jorma.tuomainen@ppoy.fi>
if(strpos($argHostname,":")) {
$argHostinfo=explode(":",$argHostname);
$argHostname=$argHostinfo[0];
.")(PORT=$argHostport))(CONNECT_DATA=(SERVICE_NAME=$argDatabasename)))";
}
- /* if ($argHostname) print "<p>Connect: 1st argument should be left blank for $this->databaseType</p>"; */
+ //if ($argHostname) print "<p>Connect: 1st argument should be left blank for $this->databaseType</p>";
if ($persist)$this->_connectionID = OCIPLogon($argUsername,$argPassword, $argDatabasename);
else $this->_connectionID = OCILogon($argUsername,$argPassword, $argDatabasename);
$this->Execute("ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD'");
}
- /* print OCIServerVersion($this->_connectionID); */
+ //print OCIServerVersion($this->_connectionID);
return true;
}
- /* returns true or false */
+ // returns true or false
function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
{
return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename,true);
*/
function &SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$arg3=false,$secs2cache=0)
{
- /* seems that oracle only supports 1 hint comment in 8i */
+ // seems that oracle only supports 1 hint comment in 8i
if (strpos($sql,'/*+') !== false)
$sql = str_replace('/*+ ','/*+FIRST_ROWS ',$sql);
else
if ($offset < 100) {
if ($nrows > 0) {
if ($offset > 0) $nrows += $offset;
- /* $inputarr['adodb_rownum'] = $nrows; */
+ //$inputarr['adodb_rownum'] = $nrows;
$sql = "select * from ($sql) where rownum <= $nrows";
$nrows = -1;
}
- /* note that $nrows = 0 still has to work ==> no rows returned */
+ // note that $nrows = 0 still has to work ==> no rows returned
return ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$arg3,$secs2cache);
} else {
- /* Algorithm by Tomas V V Cox, from PEAR DB oci8.php */
+ // Algorithm by Tomas V V Cox, from PEAR DB oci8.php
- /* Let Oracle return the name of the columns */
+ // Let Oracle return the name of the columns
$q_fields = "SELECT * FROM ($sql) WHERE NULL = NULL";
if (!$result = OCIParse($this->_connectionID, $q_fields)) {
return false;
$fields = implode(',', $cols);
$nrows += $offset;
- $offset += 1; /* in Oracle rownum starts at 1 */
+ $offset += 1; // in Oracle rownum starts at 1
$sql = "SELECT $fields FROM".
"(SELECT rownum as adodb_rownum, $fields FROM".
static $BINDNUM = 0;
$stmt = OCIParse($this->_connectionID,$sql);
- if (!$stmt) return $sql; /* error in statement, let Execute() handle the error */
+ if (!$stmt) return $sql; // error in statement, let Execute() handle the error
$BINDNUM += 1;
return array($sql,$stmt,0,$BINDNUM);
if (!is_array($stmt)) return false;
if ($name == false) {
if ($type !== false) $rez = OCIBindByName($stmt[1],":".$name,$var,$size,$type);
- else $rez = OCIBindByName($stmt[1],":".$stmt[2],$var,$size); /* +1 byte for null terminator */
+ else $rez = OCIBindByName($stmt[1],":".$stmt[2],$var,$size); // +1 byte for null terminator
$stmt[2] += 1;
} else {
if ($type !== false) $rez = OCIBindByName($stmt[1],":".$name,$var,$size,$type);
- else $rez = OCIBindByName($stmt[1],":".$name,$var,$size); /* +1 byte for null terminator */
+ else $rez = OCIBindByName($stmt[1],":".$name,$var,$size); // +1 byte for null terminator
}
return $rez;
*/
function _query($sql,$inputarr)
{
- if (is_array($sql)) { /* is prepared sql */
+ if (is_array($sql)) { // is prepared sql
$stmt = $sql[1];
- /* we try to bind to permanent array, so that OCIBindByName is persistent */
- /* and carried out once only - note that max array element size is 4000 chars */
+ // we try to bind to permanent array, so that OCIBindByName is persistent
+ // and carried out once only - note that max array element size is 4000 chars
if (is_array($inputarr)) {
$bindpos = $sql[3];
if (isset($this->_bind[$bindpos])) {
- /* all tied up already */
+ // all tied up already
$bindarr = &$this->_bind[$bindpos];
} else {
- /* one statement to bind them all */
+ // one statement to bind them all
$bindarr = array();
foreach($inputarr as $k => $v) {
$bindarr[$k] = $v;
if (is_array($inputarr)) {
foreach($inputarr as $k => $v) {
if (is_array($v)) {
- if (sizeof($v) == 2) /* suggested by g.giunta@libero. */
+ if (sizeof($v) == 2) // suggested by g.giunta@libero.
OCIBindByName($stmt,":$k",$inputarr[$k][0],$v[1]);
else
OCIBindByName($stmt,":$k",$inputarr[$k][0],$v[1],$v[2]);
} else {
$len = -1;
if ($v === ' ') $len = 1;
- if (isset($bindarr)) { /* is prepared sql, so no need to ocibindbyname again */
+ if (isset($bindarr)) { // is prepared sql, so no need to ocibindbyname again
$bindarr[$k] = $v;
- } else { /* dynamic sql, so rebind every time */
+ } else { // dynamic sql, so rebind every time
OCIBindByName($stmt,":$k",$inputarr[$k],$len);
}
}
return false;
}
- /* returns true or false */
+ // returns true or false
function _close()
{
if (!$this->autoCommit) OCIRollback($this->_connectionID);
function MetaPrimaryKeys($table)
{
- /* tested with oracle 8.1.7 */
+ // tested with oracle 8.1.7
$table = strtoupper($table);
$sql = "SELECT /*+ RULE */ distinct b.column_name
FROM ALL_CONSTRAINTS a
case 'T': return 'DATE';
case 'L': return 'NUMBER(1)';
case 'R': return false;
- case 'I': return 'NUMBER(16)'; /* enough for 9 petabytes! */
+ case 'I': return 'NUMBER(16)'; // enough for 9 petabytes!
case 'F': return 'NUMBER';
case 'N': return 'NUMBER';
return "'".str_replace("'",$this->replaceQuote,$s)."'";
}
- /* undo magic quotes for " */
+ // undo magic quotes for "
$s = str_replace('\\"','"',$s);
- if ($this->replaceQuote == "\\'") /* ' already quoted, no need to change anything */
+ if ($this->replaceQuote == "\\'") // ' already quoted, no need to change anything
return "'$s'";
- else {/* change \' to '' for sybase/mssql */
+ else {// change \' to '' for sybase/mssql
$s = str_replace('\\\\','\\',$s);
return "'".str_replace("\\'",$this->replaceQuote,$s)."'";
}
var $databaseType = 'oci8';
var $bind=false;
var $_fieldobjs;
- /* var $_arr = false; */
+ //var $_arr = false;
function ADORecordset_oci8($queryID)
{
$fld->type = OCIcolumntype($this->_queryID, $fieldOffset);
$fld->max_length = OCIcolumnsize($this->_queryID, $fieldOffset);
if ($fld->type == 'NUMBER') {
- /* $p = OCIColumnPrecision($this->_queryID, $fieldOffset); */
+ //$p = OCIColumnPrecision($this->_queryID, $fieldOffset);
$sc = OCIColumnScale($this->_queryID, $fieldOffset);
if ($sc == 0) $fld->type = 'INT';
}
*/
function GetArray($nRows = -1)
{
- /* if ($this->_arr) return $this->_arr; */
+ // if ($this->_arr) return $this->_arr;
$results = array();
$cnt = 0;
while (!$this->EOF && $nRows != $cnt) {
return $results;
}
- /* 10% speedup to move MoveNext to child class */
+ // 10% speedup to move MoveNext to child class
function MoveNext()
{
if (!$this->EOF) {
case 'DATE':
return 'D';
- /* case 'T': return 'T'; */
+ //case 'T': return 'T';
case 'INT':
case 'SMALLINT':
function &SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$arg3=false,$secs2cache=0)
{
- /* seems that oracle only supports 1 hint comment in 8i */
+ // seems that oracle only supports 1 hint comment in 8i
if (strpos($sql,'/*+') !== false)
$sql = str_replace('/*+ ','/*+FIRST_ROWS ',$sql);
else
return ADODB_oci8::Prepare($sql);
}
- /* emulate handling of parameters ? ?, replacing with :bind0 :bind1 */
+ // emulate handling of parameters ? ?, replacing with :bind0 :bind1
function _query($sql,$inputarr)
{
if (is_array($inputarr)) {
return $this->fields[$this->bind[strtoupper($colname)]];
}
- /* lowercase field names... */
+ // lowercase field names...
function &_FetchField($fieldOffset = -1)
{
$fld = new ADOFieldObject;
$fld->type = OCIcolumntype($this->_queryID, $fieldOffset);
$fld->max_length = OCIcolumnsize($this->_queryID, $fieldOffset);
if ($fld->type == 'NUMBER') {
- /* $p = OCIColumnPrecision($this->_queryID, $fieldOffset); */
+ //$p = OCIColumnPrecision($this->_queryID, $fieldOffset);
$sc = OCIColumnScale($this->_queryID, $fieldOffset);
if ($sc == 0) $fld->type = 'INT';
}
return $fld;
}
- /* 10% speedup to move MoveNext to child class */
+ // 10% speedup to move MoveNext to child class
function MoveNext()
{
if (!$this->EOF) {
return $results;
}
- /* Uggh - a useless slowdown */
+ // Uggh - a useless slowdown
function _updatefields()
{
$arr = array();
var $databaseType = "odbc";
var $fmtDate = "'Y-m-d'";
var $fmtTimeStamp = "'Y-m-d, h:i:sA'";
- var $replaceQuote = "''"; /* string to use to replace quotes */
+ var $replaceQuote = "''"; // string to use to replace quotes
var $dataProvider = "odbc";
var $hasAffectedRows = true;
var $binmode = ODBC_BINMODE_RETURN;
- /* var $longreadlen = 8000; // default number of chars to return for a Blob/Long field */
+ //var $longreadlen = 8000; // default number of chars to return for a Blob/Long field
var $_bindInputArray = false;
- var $curmode = SQL_CUR_USE_DRIVER; /* See sqlext.h, SQL_CUR_DEFAULT == SQL_CUR_USE_DRIVER == 2L */
+ var $curmode = SQL_CUR_USE_DRIVER; // See sqlext.h, SQL_CUR_DEFAULT == SQL_CUR_USE_DRIVER == 2L
var $_genSeqSQL = "create table %s (id integer)";
var $_autocommit = true;
var $_haserrorfunctions = true;
*/
function GenID($seq='adodbseq',$start=1)
{
- /* if you have to modify the parameter below, your database is overloaded, */
- /* or you need to implement generation of id's yourself! */
+ // if you have to modify the parameter below, your database is overloaded,
+ // or you need to implement generation of id's yourself!
$MAXLOOPS = 100;
while (--$MAXLOOPS>=0) {
if (empty($this->_connectionID)) $e = @odbc_error();
else $e = @odbc_error($this->_connectionID);
- /* bug in 4.0.6, error number can be corrupted string (should be 6 digits) */
- /* so we check and patch */
+ // bug in 4.0.6, error number can be corrupted string (should be 6 digits)
+ // so we check and patch
if (strlen($e)<=2) return 0;
return $e;
} else return ADOConnection::ErrorNo();
}
- /* returns true or false */
+ // returns true or false
function _connect($argDSN, $argUsername, $argPassword, $argDatabasename)
{
global $php_errormsg;
$this->_connectionID = odbc_connect($argDSN,$argUsername,$argPassword,$this->curmode);
$this->_errorMsg = $php_errormsg;
- /* if ($this->_connectionID) odbc_autocommit($this->_connectionID,true); */
+ //if ($this->_connectionID) odbc_autocommit($this->_connectionID,true);
return $this->_connectionID != false;
}
- /* returns true or false */
+ // returns true or false
function _pconnect($argDSN, $argUsername, $argPassword, $argDatabasename)
{
global $php_errormsg;
$this->_connectionID = odbc_pconnect($argDSN,$argUsername,$argPassword,$this->curmode);
$this->_errorMsg = $php_errormsg;
- /* if ($this->_connectionID) odbc_autocommit($this->_connectionID,true); */
+ //if ($this->_connectionID) odbc_autocommit($this->_connectionID,true);
return $this->_connectionID != false;
}
$rs->_has_stupid_odbc_fetch_api_change = $this->_has_stupid_odbc_fetch_api_change;
- /* print_r($rs); */
+ //print_r($rs);
$arr = $rs->GetArray();
$rs->Close();
$arr2 = array();
case 12:
case 0:
return 'C';
- case -1: /* text */
+ case -1: //text
return 'X';
- case -4: /* image */
+ case -4: //image
return 'B';
case 91:
case -6:
return 'I';
- case -11: /* uniqidentifier */
+ case -11: // uniqidentifier
return 'R';
- case -7: /* bit */
+ case -7: //bit
return 'L';
default:
break;
$rs->MoveNext();
}
- $rs->Close(); /* -- crashes 4.03pl1 -- why? */
+ $rs->Close(); //-- crashes 4.03pl1 -- why?
return $retarr;
}
function Prepare($sql)
{
- if (! $this->_bindInputArray) return $sql; /* no binding */
+ if (! $this->_bindInputArray) return $sql; // no binding
$stmt = odbc_prepare($this->_connectionID,$sql);
if (!$stmt) {
- /* print "Prepare Error for ($sql) ".$this->ErrorMsg()."<br>"; */
+ // print "Prepare Error for ($sql) ".$this->ErrorMsg()."<br>";
return $sql;
}
return array($sql,$stmt,false);
return $this->Execute("UPDATE $table SET $column=? WHERE $where",array($val)) != false;
}
- /* returns true or false */
+ // returns true or false
function _close()
{
$ret = @odbc_close($this->_connectionID);
}
- /* returns the field object */
+ // returns the field object
function &FetchField($fieldOffset = -1) {
- $off=$fieldOffset+1; /* offsets begin at 1 */
+ $off=$fieldOffset+1; // offsets begin at 1
$o= new ADOFieldObject();
$o->name = @odbc_field_name($this->_queryID,$off);
return false;
}
- /* speed up SelectLimit() by switching to ADODB_FETCH_NUM as ADODB_FETCH_ASSOC is emulated */
+ // speed up SelectLimit() by switching to ADODB_FETCH_NUM as ADODB_FETCH_ASSOC is emulated
function GetArrayLimit($nrows,$offset=-1)
{
if ($offset <= 0) return $this->GetArray($nrows);
var $fmtDate = "'Y-m-d'";
var $fmtTimeStamp = "'Y-m-d h:i:sA'";
var $_bindInputArray = true;
- var $hasTop = 'top'; /* support mssql/interbase SELECT TOP 10 * FROM TABLE */
+ var $hasTop = 'top'; // support mssql/interbase SELECT TOP 10 * FROM TABLE
var $sysDate = 'GetDate()';
var $sysTimeStamp = 'GetDate()';
class ADODB_odbc_oracle extends ADODB_odbc {
var $databaseType = 'odbc_oracle';
- var $replaceQuote = "''"; /* string to use to replace quotes */
+ var $replaceQuote = "''"; // string to use to replace quotes
var $concat_operator='||';
var $fmtDate = "'Y-m-d 00:00:00'";
var $fmtTimeStamp = "'Y-m-d h:i:sA'";
var $sysDate = "TO_DATE(TO_CHAR(SYSDATE,'YYYY-MM-DD'),'YYYY-MM-DD')";
var $sysTimeStamp = 'SYSDATE';
- /* var $_bindInputArray = false; */
+ //var $_bindInputArray = false;
function ADODB_odbc_oracle()
{
if ($rs === false) return false;
$retarr = array();
- while (!$rs->EOF) { /* print_r($rs->fields); */
+ while (!$rs->EOF) { //print_r($rs->fields);
$fld = new ADOFieldObject();
$fld->name = $rs->fields[0];
$fld->type = $rs->fields[1];
return false;
}
- /* returns true or false */
+ // returns true or false
function _connect($argDSN, $argUsername, $argPassword, $argDatabasename)
{
global $php_errormsg;
$this->_errorMsg = $php_errormsg;
$this->Execute("ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'");
- /* if ($this->_connectionID) odbc_autocommit($this->_connectionID,true); */
+ //if ($this->_connectionID) odbc_autocommit($this->_connectionID,true);
return $this->_connectionID != false;
}
- /* returns true or false */
+ // returns true or false
function _pconnect($argDSN, $argUsername, $argPassword, $argDatabasename)
{
global $php_errormsg;
$this->_errorMsg = $php_errormsg;
$this->Execute("ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'");
- /* if ($this->_connectionID) odbc_autocommit($this->_connectionID,true); */
+ //if ($this->_connectionID) odbc_autocommit($this->_connectionID,true);
return $this->_connectionID != false;
}
}
*/
-/* select table_name from cat -- MetaTables */
-/* */
+// select table_name from cat -- MetaTables
+//
class ADODB_oracle extends ADOConnection {
var $databaseType = "oracle";
- var $replaceQuote = "\'"; /* string to use to replace quotes */
+ var $replaceQuote = "\'"; // string to use to replace quotes
var $concat_operator='||';
var $_curs;
- var $_initdate = true; /* init date to YYYY-MM-DD */
+ var $_initdate = true; // init date to YYYY-MM-DD
var $metaTablesSQL = 'select table_name from cat';
var $metaColumnsSQL = "select cname,coltype,width from col where tname='%s' order by colno";
var $sysDate = "TO_DATE(TO_CHAR(SYSDATE,'YYYY-MM-DD'),'YYYY-MM-DD')";
{
}
- /* format and return date string in database date format */
+ // format and return date string in database date format
function DBDate($d)
{
if (is_string($d)) $d = ADORecordSet::UnixDate($d);
return 'TO_DATE('.date($this->fmtDate,$d).",'YYYY-MM-DD')";
}
- /* format and return date string in database timestamp format */
+ // format and return date string in database timestamp format
function DBTimeStamp($ts)
{
if (is_string($ts)) $d = ADORecordSet::UnixTimeStamp($ts);
}
- /* returns true or false */
+ // returns true or false
function _connect($argHostname, $argUsername, $argPassword, $argDatabasename)
{
if ($argHostname) putenv("ORACLE_HOME=$argHostname");
if ($argDatabasename) $argUsername .= "@$argDatabasename";
- /* if ($argHostname) print "<p>Connect: 1st argument should be left blank for $this->databaseType</p>"; */
+ //if ($argHostname) print "<p>Connect: 1st argument should be left blank for $this->databaseType</p>";
$this->_connectionID = ora_logon($argUsername,$argPassword);
if ($this->_connectionID === false) return false;
if ($this->autoCommit) ora_commiton($this->_connectionID);
return true;
}
- /* returns true or false */
+ // returns true or false
function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
{
if ($argHostname) putenv("ORACLE_HOME=$argHostname");
if ($argDatabasename) $argUsername .= "@$argDatabasename";
- /* if ($argHostname) print "<p>PConnect: 1st argument should be left blank for $this->databaseType</p>"; */
+ //if ($argHostname) print "<p>PConnect: 1st argument should be left blank for $this->databaseType</p>";
$this->_connectionID = ora_plogon($argUsername,$argPassword);
if ($this->_connectionID === false) return false;
if ($this->autoCommit) ora_commiton($this->_connectionID);
return true;
}
- /* returns query ID if successful, otherwise false */
+ // returns query ID if successful, otherwise false
function _query($sql,$inputarr)
{
$curs = ora_open($this->_connectionID);
return false;
}
- /* returns true or false */
+ // returns true or false
function _close()
{
if (!$this->autoCommit) ora_rollback($this->_connectionID);
}
function _fetch($ignore_fields=false) {
-/* should remove call by reference, but ora_fetch_into requires it in 4.0.3pl1 */
+// should remove call by reference, but ora_fetch_into requires it in 4.0.3pl1
if ($this->fetchMode & ADODB_FETCH_ASSOC)
return @ora_fetch_into($this->_queryID,&$this->fields,ORA_FETCHINTO_NULLS|ORA_FETCHINTO_ASSOC);
else
case 'DATE': return 'D';
- /* case 'T': return 'T'; */
+ //case 'T': return 'T';
case 'BIT': return 'L';
case 'INT':
class ADODB_postgres extends ADODB_postgres64 {
var $databaseType = 'postgres';
- var $hasLimit = true; /* set to true for pgsql 6.5+ only. support pgsql/mysql SELECT * FROM TABLE LIMIT 10 */
+ var $hasLimit = true; // set to true for pgsql 6.5+ only. support pgsql/mysql SELECT * FROM TABLE LIMIT 10
function ADODB_postgres()
{
}
- /* the following should be compat with postgresql 7.2, */
- /* which makes obsolete the LIMIT limit,offset syntax */
+ // the following should be compat with postgresql 7.2,
+ // which makes obsolete the LIMIT limit,offset syntax
function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$arg3=false,$secs2cache=0)
{
$offsetStr = ($offset >= 0) ? " OFFSET $offset" : '';
$this->Execute($sql."$limitStr$offsetStr",$inputarr,$arg3);
}
- /* 10% speedup to move MoveNext to child class */
+ // 10% speedup to move MoveNext to child class
function MoveNext()
{
if (!$this->EOF) {
var $_resultid = false;
var $concat_operator='||';
var $metaTablesSQL = "select tablename from pg_tables where tablename not like 'pg_%' order by 1";
- var $isoDates = true; /* accepts dates in ISO format */
+ var $isoDates = true; // accepts dates in ISO format
var $sysDate = "CURRENT_DATE";
var $sysTimeStamp = "CURRENT_TIMESTAMP";
SELECT tablename FROM pg_tables WHERE tablename NOT LIKE 'pg_%' ORDER BY 1"
*/
var $metaColumnsSQL = "SELECT a.attname,t.typname,a.attlen,a.atttypmod,a.attnotnull,a.atthasdef,a.attnum FROM pg_class c, pg_attribute a,pg_type t WHERE relkind = 'r' AND c.relname='%s' AND a.attnum > 0 AND a.atttypid = t.oid AND a.attrelid = c.oid ORDER BY a.attnum";
- /* get primary key etc -- from Freek Dijkstra */
+ // get primary key etc -- from Freek Dijkstra
var $metaKeySQL = "SELECT ic.relname AS index_name, a.attname AS column_name,i.indisunique AS unique_key, i.indisprimary AS primary_key FROM pg_class bc, pg_class ic, pg_index i, pg_attribute a WHERE bc.oid = i.indrelid AND ic.oid = i.indexrelid AND (i.indkey[0] = a.attnum OR i.indkey[1] = a.attnum OR i.indkey[2] = a.attnum OR i.indkey[3] = a.attnum OR i.indkey[4] = a.attnum OR i.indkey[5] = a.attnum OR i.indkey[6] = a.attnum OR i.indkey[7] = a.attnum) AND a.attrelid = bc.oid AND bc.relname = '%s'";
var $_hastrans = false;
var $hasAffectedRows = true;
- var $hasLimit = false; /* set to true for pgsql 7 only. support pgsql/mysql SELECT * FROM TABLE LIMIT 10 */
- /* below suggested by Freek Dijkstra */
- var $true = 't'; /* string that represents TRUE for a database */
- var $false = 'f'; /* string that represents FALSE for a database */
- var $fmtDate = "'Y-m-d'"; /* used by DBDate() as the default date format used by the database */
- var $fmtTimeStamp = "'Y-m-d G:i:s'"; /* used by DBTimeStamp as the default timestamp fmt. */
+ var $hasLimit = false; // set to true for pgsql 7 only. support pgsql/mysql SELECT * FROM TABLE LIMIT 10
+ // below suggested by Freek Dijkstra
+ var $true = 't'; // string that represents TRUE for a database
+ var $false = 'f'; // string that represents FALSE for a database
+ var $fmtDate = "'Y-m-d'"; // used by DBDate() as the default date format used by the database
+ var $fmtTimeStamp = "'Y-m-d G:i:s'"; // used by DBTimeStamp as the default timestamp fmt.
var $hasMoveFirst = true;
var $hasGenID = true;
var $_genIDSQL = "SELECT NEXTVAL('%s')";
var $_genSeqSQL = "CREATE SEQUENCE %s START %s";
var $metaDefaultsSQL = "SELECT d.adnum as num, d.adsrc as def from pg_attrdef d, pg_class c where d.adrelid=c.oid and c.relname='%s' order by d.adnum";
- /* The last (fmtTimeStamp is not entirely correct: */
- /* PostgreSQL also has support for time zones, */
- /* and writes these time in this format: "2001-03-01 18:59:26+02". */
- /* There is no code for the "+02" time zone information, so I just left that out. */
- /* I'm not familiar enough with both ADODB as well as Postgres */
- /* to know what the concequences are. The other values are correct (wheren't in 0.94) */
- /* -- Freek Dijkstra */
+ // The last (fmtTimeStamp is not entirely correct:
+ // PostgreSQL also has support for time zones,
+ // and writes these time in this format: "2001-03-01 18:59:26+02".
+ // There is no code for the "+02" time zone information, so I just left that out.
+ // I'm not familiar enough with both ADODB as well as Postgres
+ // to know what the concequences are. The other values are correct (wheren't in 0.94)
+ // -- Freek Dijkstra
function ADODB_postgres64()
{
- /* changes the metaColumnsSQL, adds columns: attnum[6] */
+ // changes the metaColumnsSQL, adds columns: attnum[6]
}
- /* get the last id - never tested */
+ // get the last id - never tested
function pg_insert_id($tablename,$fieldname)
{
$result=pg_exec($this->_connectionID, "SELECT last_value FROM ${tablename}_${fieldname}_seq");
return pg_getlastoid($this->_resultid);
}
-/* I get this error with PHP before 4.0.6 - jlim */
-/* Warning: This compilation does not support pg_cmdtuples() in d:/inetpub/wwwroot/php/adodb/adodb-postgres.inc.php on line 44 */
+// I get this error with PHP before 4.0.6 - jlim
+// Warning: This compilation does not support pg_cmdtuples() in d:/inetpub/wwwroot/php/adodb/adodb-postgres.inc.php on line 44
function _affectedrows()
{
return pg_cmdtuples($this->_resultid);
}
- /* returns true/false */
+ // returns true/false
function BeginTrans()
{
$this->_hastrans = true;
return $this->GetOne("select 1 as ignore from $tables where $where for update");
}
- /* returns true/false. */
+ // returns true/false.
function CommitTrans($ok=true)
{
if (!$ok) return $this->RollbackTrans();
return @pg_Exec($this->_connectionID, "commit");
}
- /* returns true/false */
+ // returns true/false
function RollbackTrans()
{
$this->_hastrans = false;
}
- /* converts table names to lowercase */
+ // converts table names to lowercase
function &MetaColumns($table)
{
global $ADODB_FETCH_MODE;
if (!empty($this->metaColumnsSQL)) {
- /* the following is the only difference -- we lowercase it */
+ // the following is the only difference -- we lowercase it
$save = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
if ($rs === false) return false;
if (!empty($this->metaKeySQL)) {
- /* If we want the primary keys, we have to issue a separate query */
- /* Of course, a modified version of the metaColumnsSQL query using a */
- /* LEFT JOIN would have been much more elegant, but postgres does */
- /* not support OUTER JOINS. So here is the clumsy way. */
+ // If we want the primary keys, we have to issue a separate query
+ // Of course, a modified version of the metaColumnsSQL query using a
+ // LEFT JOIN would have been much more elegant, but postgres does
+ // not support OUTER JOINS. So here is the clumsy way.
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
$rskey = $this->Execute(sprintf($this->metaKeySQL,strtolower($table)));
- /* fetch all result in once for performance. */
+ // fetch all result in once for performance.
$keys = $rskey->GetArray();
$ADODB_FETCH_MODE = $save;
}
$retarr = array();
- while (!$rs->EOF) { /* print_r($rs->fields); */
+ while (!$rs->EOF) { //print_r($rs->fields);
$fld = new ADOFieldObject();
$fld->name = $rs->fields[0];
$fld->type = $rs->fields[1];
if ($fld->max_length <= 0) $fld->max_length = $rs->fields[3]-4;
if ($fld->max_length <= 0) $fld->max_length = -1;
- /* dannym */
- /* 5 hasdefault; 6 num-of-column */
+ // dannym
+ // 5 hasdefault; 6 num-of-column
$fld->has_default = ($rs->fields[5] == 't');
if ($fld->has_default) {
$fld->default_value = $rsdefa[$rs->fields[6]];
}
- /* Freek */
+ //Freek
if ($rs->fields[4] == $this->true) {
$fld->not_null = true;
}
- /* Freek */
+ // Freek
if (is_array($keys)) {
reset ($keys);
while (list($x,$key) = each($keys)) {
if ($fld->name == $key['column_name'] AND $key['primary_key'] == $this->true)
$fld->primary_key = true;
if ($fld->name == $key['column_name'] AND $key['unique_key'] == $this->true)
- $fld->unique = true; /* What name is more compatible? */
+ $fld->unique = true; // What name is more compatible?
}
}
}
- /* returns true or false */
- /* */
- /* examples: */
- /* $db->Connect("host=host1 user=user1 password=secret port=4341"); */
- /* $db->Connect('host1','user1','secret'); */
+ // returns true or false
+ //
+ // examples:
+ // $db->Connect("host=host1 user=user1 password=secret port=4341");
+ // $db->Connect('host1','user1','secret');
function _connect($str,$user='',$pwd='',$db='')
{
if ($user || $pwd || $db) {
if ($db) $str .= " dbname=".$db;
}
- /* if ($user) $linea = "user=$user host=$linea password=$pwd dbname=$db port=5432"; */
+ //if ($user) $linea = "user=$user host=$linea password=$pwd dbname=$db port=5432";
$this->_connectionID = pg_connect($str);
if ($this->_connectionID === false) return false;
$this->Execute("set datestyle='ISO'");
return true;
}
- /* returns true or false */
- /* */
- /* examples: */
- /* $db->PConnect("host=host1 user=user1 password=secret port=4341"); */
- /* $db->PConnect('host1','user1','secret'); */
+ // returns true or false
+ //
+ // examples:
+ // $db->PConnect("host=host1 user=user1 password=secret port=4341");
+ // $db->PConnect('host1','user1','secret');
function _pconnect($str,$user='',$pwd='',$db='')
{
if ($user || $pwd || $db) {
if ($user) $str .= " user=".$user;
if ($pwd) $str .= " password=".$pwd;
if ($db) $str .= " dbname=".$db;
- }/* print $str; */
+ }//print $str;
$this->_connectionID = pg_pconnect($str);
if ($this->_connectionID === false) return false;
$this->Execute("set datestyle='ISO'");
return true;
}
- /* returns queryID or false */
+ // returns queryID or false
function _query($sql,$inputarr)
{
$this->_resultid= pg_Exec($this->_connectionID,$sql);
return $this->_errorMsg;
}
- /* returns true or false */
+ // returns true or false
function _close()
{
if ($this->_hastrans) $this->RollbackTrans();
*/
function CharMax()
{
- return 1000000000; /* should be 1 Gb? */
+ return 1000000000; // should be 1 Gb?
}
/*
*/
function TextMax()
{
- return 1000000000; /* should be 1 Gb? */
+ return 1000000000; // should be 1 Gb?
}
function &FetchField($fieldOffset = 0)
{
- $off=$fieldOffset; /* offsets begin at 0 */
+ $off=$fieldOffset; // offsets begin at 0
$o= new ADOFieldObject();
$o->name = @pg_fieldname($this->_queryID,$off);
$o->type = @pg_fieldtype($this->_queryID,$off);
$o->max_length = @pg_fieldsize($this->_queryID,$off);
- /* print_r($o); */
- /* print "off=$off name=$o->name type=$o->type len=$o->max_length<br>"; */
+ //print_r($o);
+ //print "off=$off name=$o->name type=$o->type len=$o->max_length<br>";
return $o;
}
return @pg_fetch_row($this->_queryID,$row);
}
- /* 10% speedup to move MoveNext to child class */
+ // 10% speedup to move MoveNext to child class
function MoveNext()
{
if (!$this->EOF) {
case 'TEXT':
return 'X';
- case 'IMAGE': /* user defined type */
- case 'BLOB': /* user defined type */
- case 'BIT': /* This is a bit string, not a single bit, so don't return 'L' */
+ case 'IMAGE': // user defined type
+ case 'BLOB': // user defined type
+ case 'BIT': // This is a bit string, not a single bit, so don't return 'L'
case 'VARBIT':
case 'BYTEA':
return 'B';
class ADODB_postgres7 extends ADODB_postgres64 {
var $databaseType = 'postgres7';
- var $hasLimit = true; /* set to true for pgsql 6.5+ only. support pgsql/mysql SELECT * FROM TABLE LIMIT 10 */
+ var $hasLimit = true; // set to true for pgsql 6.5+ only. support pgsql/mysql SELECT * FROM TABLE LIMIT 10
function ADODB_postgres7()
{
}
- /* the following should be compat with postgresql 7.2, */
- /* which makes obsolete the LIMIT limit,offset syntax */
+ // the following should be compat with postgresql 7.2,
+ // which makes obsolete the LIMIT limit,offset syntax
function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$arg3=false,$secs2cache=0)
{
$offsetStr = ($offset >= 0) ? " OFFSET $offset" : '';
$this->Execute($sql."$limitStr$offsetStr",$inputarr,$arg3);
}
- /* 10% speedup to move MoveNext to child class */
+ // 10% speedup to move MoveNext to child class
function MoveNext()
{
if (!$this->EOF) {
$this->ADORecordset($id);
}
};
-} /* define */
+} // define
?>
\ No newline at end of file
$this->drop_blobvar($blobVarName);
return true;
}
- }; /* class */
+ }; //class
class ADORecordSet_sqlanywhere extends ADORecordSet_odbc {
}
- }; /* class */
+ }; //class
-} /* define */
+} //define
?>
class ADODB_sybase extends ADOConnection {
var $databaseType = "sybase";
- var $replaceQuote = "''"; /* string to use to replace quotes */
+ var $replaceQuote = "''"; // string to use to replace quotes
var $fmtDate = "'Y-m-d'";
var $fmtTimeStamp = "'Y-m-d H:i:s'";
var $hasInsertID = true;
{
}
- /* might require begintrans -- committrans */
+ // might require begintrans -- committrans
function _insertid()
{
return $this->GetOne('select @@identity');
}
- /* might require begintrans -- committrans */
+ // might require begintrans -- committrans
function _affectedrows()
{
return $this->GetOne('select @@rowcount');
return true;
}
- /* http://www.isug.com/Sybase_FAQ/ASE/section6.1.html#6.1.4 */
+ // http://www.isug.com/Sybase_FAQ/ASE/section6.1.html#6.1.4
function RowLock($tables,$where)
{
if (!$this->_hastrans) $this->BeginTrans();
return $this->_errorMsg;
}
- /* returns true or false */
+ // returns true or false
function _connect($argHostname, $argUsername, $argPassword, $argDatabasename)
{
$this->_connectionID = sybase_connect($argHostname,$argUsername,$argPassword);
if ($argDatabasename) return $this->SelectDB($argDatabasename);
return true;
}
- /* returns true or false */
+ // returns true or false
function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
{
$this->_connectionID = sybase_pconnect($argHostname,$argUsername,$argPassword);
return true;
}
- /* returns query ID if successful, otherwise false */
+ // returns query ID if successful, otherwise false
function _query($sql,$inputarr)
{
- /* @sybase_free_result($this->_queryID); */
+ //@sybase_free_result($this->_queryID);
return sybase_query($sql,$this->_connectionID);
}
- /* See http://www.isug.com/Sybase_FAQ/ASE/section6.2.html#6.2.12 */
+ // See http://www.isug.com/Sybase_FAQ/ASE/section6.2.html#6.2.12
function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$arg3=false,$secs2cache=0)
{
$cnt = ($nrows > 0) ? $nrows : 0;
return $rs;
}
- /* returns true or false */
+ // returns true or false
function _close()
{
return @sybase_close($this->_connectionID);
var $databaseType = "sybase";
var $canSeek = true;
- /* _mths works only in non-localised system */
+ // _mths works only in non-localised system
var $_mths = array('JAN'=>1,'FEB'=>2,'MAR'=>3,'APR'=>4,'MAY'=>5,'JUN'=>6,'JUL'=>7,'AUG'=>8,'SEP'=>9,'OCT'=>10,'NOV'=>11,'DEC'=>12);
function ADORecordset_sybase($id)
else if ($fieldOffset == -1) { /* The $fieldOffset argument is not provided thus its -1 */
$o = @sybase_fetch_field($this->_queryID);
}
- /* older versions of PHP did not support type, only numeric */
+ // older versions of PHP did not support type, only numeric
if ($o && !isset($o->type)) $o->type = ($o->numeric) ? 'float' : 'varchar';
return $o;
}
return @sybase_free_result($this->_queryID);
}
- /* sybase/mssql uses a default date like Dec 30 2000 12:00AM */
+ // sybase/mssql uses a default date like Dec 30 2000 12:00AM
function UnixDate($v)
{
return ADORecordSet_array_sybase::UnixDate($v);
$this->ADORecordSet_array($id);
}
- /* sybase/mssql uses a default date like Dec 30 2000 12:00AM */
+ // sybase/mssql uses a default date like Dec 30 2000 12:00AM
function UnixDate($v)
{
global $ADODB_sybase_mths;
- /* Dec 30 2000 12:00AM */
+ //Dec 30 2000 12:00AM
if (!ereg( "([A-Za-z]{3})[-/\. ]+([0-9]{1,2})[-/\. ]+([0-9]{4})"
,$v, $rr)) return parent::UnixDate($v);
$themth = substr(strtoupper($rr[1]),0,3);
$themth = $ADODB_sybase_mths[$themth];
if ($themth <= 0) return false;
- /* h-m-s-MM-DD-YY */
+ // h-m-s-MM-DD-YY
return mktime(0,0,0,$themth,$rr[2],$rr[3]);
}
function UnixTimeStamp($v)
{
global $ADODB_sybase_mths;
- /* 11.02.2001 Toni Tunkkari toni.tunkkari@finebyte.com */
- /* Changed [0-9] to [0-9 ] in day conversion */
+ //11.02.2001 Toni Tunkkari toni.tunkkari@finebyte.com
+ //Changed [0-9] to [0-9 ] in day conversion
if (!ereg( "([A-Za-z]{3})[-/\. ]([0-9 ]{1,2})[-/\. ]([0-9]{4}) +([0-9]{1,2}):([0-9]{1,2}) *([apAP]{0,1})"
,$v, $rr)) return parent::UnixTimeStamp($v);
if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0;
default:
break;
}
- /* h-m-s-MM-DD-YY */
+ // h-m-s-MM-DD-YY
return mktime($rr[4],$rr[5],0,$themth,$rr[2],$rr[3]);
}
}
var $replaceQuote = "'+chr(39)+'" ;
var $true = '.T.';
var $false = '.F.';
- var $hasTop = 'top'; /* support mssql SELECT TOP 10 * FROM TABLE */
+ var $hasTop = 'top'; // support mssql SELECT TOP 10 * FROM TABLE
var $upperCase = 'upper';
- var $_bindInputArray = false; /* strangely enough, setting to true does not work reliably */
+ var $_bindInputArray = false; // strangely enough, setting to true does not work reliably
var $sysTimeStamp = 'datetime()';
var $sysDate = 'date()';
function BeginTrans() { return false;}
- /* quote string to be sent back to database */
+ // quote string to be sent back to database
function qstr($s,$nofixquotes=false)
{
if (!$nofixquotes) return "'".str_replace("\r\n","'+chr(13)+'",str_replace("'",$this->replaceQuote,$s))."'";
}
- /* TOP requires ORDER BY for VFP */
+ // TOP requires ORDER BY for VFP
function &SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$arg3=false,$secs2cache=0)
{
if (!preg_match('/ORDER[ \t\r\n]+BY/i',$sql)) $sql .= ' ORDER BY 1';
}
}
-} /* define */
+} //define
?>
\ No newline at end of file
will contribute drivers to support other databases.</p>
<p>PHP4 supports session variables. You can store your session information using
ADOdb for true portability and scalability. See ADOdb-session.php for more information.</p>
-<p>Also read <a href="http:/* php.weblogs.com/portable_sql">http://php.weblogs.com/portable_sql</a> */
+<p>Also read <a href="http://php.weblogs.com/portable_sql">http://php.weblogs.com/portable_sql</a>
(also available as tips_portable_sql.htm in the release) for tips on writing
portable SQL.</p>
<h2>Unique Features of ADOdb<a name="features"></a></h2>
</ul>
<h2>How People are using ADOdb<a name="users"></a></h2>
Here are some examples of how people are using ADOdb (for a much longer list,
-visit <a href="http:/* php.weblogs.com/adodb-cool-applications">http://php.weblogs.com/ADOdb-cool-applications</a>): */
+visit <a href="http://php.weblogs.com/adodb-cool-applications">http://php.weblogs.com/ADOdb-cool-applications</a>):
<ul>
-<li><a href="http:/* phplens.com/">PhpLens</a> is a commercial data grid component that allows both cool Web designers and serious unshaved programmers to develop and maintain databases on the Web easily. Developed by the author of ADOdb.<p> */
+<li><a href="http://phplens.com/">PhpLens</a> is a commercial data grid component that allows both cool Web designers and serious unshaved programmers to develop and maintain databases on the Web easily. Developed by the author of ADOdb.<p>
-<li><a href="http:/* www.interakt.ro/phakt/">PHAkt: PHP Extension for DreamWeaver Ultradev</a> allows you to script PHP in the popular Web page editor. Database handling provided by ADOdb.<p> */
+<li><a href="http://www.interakt.ro/phakt/">PHAkt: PHP Extension for DreamWeaver Ultradev</a> allows you to script PHP in the popular Web page editor. Database handling provided by ADOdb.<p>
-<li><a href="http:/* www.andrew.cmu.edu/~rdanyliw/snort/snortacid.html">Analysis Console for Intrusion Databases</a> (ACID): PHP-based analysis engine to search and process a database of security incidents generated by security-related software such as IDSes and firewalls (e.g. Snort, ipchains). By Roman Danyliw.<p> */
+<li><a href="http://www.andrew.cmu.edu/~rdanyliw/snort/snortacid.html">Analysis Console for Intrusion Databases</a> (ACID): PHP-based analysis engine to search and process a database of security incidents generated by security-related software such as IDSes and firewalls (e.g. Snort, ipchains). By Roman Danyliw.<p>
-<li><a href="http:/* www.postnuke.com/">PostNuke</a> is a very popular free content management */
+<li><a href="http://www.postnuke.com/">PostNuke</a> is a very popular free content management
system and weblog system. It offers full CSS support, HTML 4.01 transitional compliance throughout, an advanced blocks system, and is fully multi-lingual enabled. <p>
-<li><a href=http:/* www.auto-net.no/easypublish.php?page=index&lang_id=2>EasyPublish CMS</a> is another free content management system for managing information and integrated modules on your internet, intranet- and extranet-sites. From Norway.<p> */
+<li><a href=http://www.auto-net.no/easypublish.php?page=index&lang_id=2>EasyPublish CMS</a> is another free content management system for managing information and integrated modules on your internet, intranet- and extranet-sites. From Norway.<p>
-<li><a href="http:/* nola.noguska.com/">NOLA</a> is a full featured accounting, inventory, and job tracking application. It is licensed under the GPL, and developed by Noguska. */
+<li><a href="http://nola.noguska.com/">NOLA</a> is a full featured accounting, inventory, and job tracking application. It is licensed under the GPL, and developed by Noguska.
</ul><p>
<h2>Feature Requests and Bug Reports<a name="bugs"></a></h2>
<p>Feature requests and bug reports can be emailed to <a href="mailto:jlim#natsoft.com.my">jlim#natsoft.com.my</a>
- or posted to the ADOdb Help forums at <a href="http:/* phplens.com/lens/lensforum/topics.php?id=4">http://phplens.com/lens/lensforum/topics.php?id=4</a>.</p> */
+ or posted to the ADOdb Help forums at <a href="http://phplens.com/lens/lensforum/topics.php?id=4">http://phplens.com/lens/lensforum/topics.php?id=4</a>.</p>
<h2>Installation Guide<a name="install"></a></h2>
<p>Make sure you are running PHP4.01pl2 or later (it uses require_once and include_once).
Unpack all the files into a directory accessible by your webserver.</p>
<td height="54"><font size="2">Y/N</font></td>
<td height="54"><font size="2">DB2 CLI/ODBC interface</font></td>
<td height="54">
- <p><font size="2">Unix and Windows. <a href="http:/* www.faqts.com/knowledge_base/view.phtml/aid/6283/fid/14">Unix */
+ <p><font size="2">Unix and Windows. <a href="http://www.faqts.com/knowledge_base/view.phtml/aid/6283/fid/14">Unix
install hints</a>.</font></p>
</td>
</tr>
<td height="73"><font size="2">Y/N</font></td>
<td height="73"><font size="2">Mssql client</font></td>
<td height="73">
- <p><font size="2">Unix and Windows. <a href="http:/* phpbuilder.com/columns/alberto20000919.php3"><br> */
+ <p><font size="2">Unix and Windows. <a href="http://phpbuilder.com/columns/alberto20000919.php3"><br>
Unix install howto</a>.</font></p>
</td>
</tr>
PConnect('DSN','user','pwd').</font></td>
<td><font size="2">? depends on database</font></td>
<td><font size="2">ODBC</font></td>
- <td><font size="2">Unix and Windows. <a href="http:/* phpbuilder.com/columns/alberto20000919.php3?page=4">Unix */
+ <td><font size="2">Unix and Windows. <a href="http://phpbuilder.com/columns/alberto20000919.php3?page=4">Unix
hints.</a></font></td>
</tr>
<tr valign="top">
<p>
ADOdb provides two custom handlers which you can modify for your needs.
The first one is in the <b>ADOdb-errorhandler.inc.php</b> file. This makes
-use of the standard PHP functions <a href=http:/* php.net/error_reporting>error_reporting</a> */
+use of the standard PHP functions <a href=http://php.net/error_reporting>error_reporting</a>
to control what error messages types to display,
-and <a href=http:/* php.net/trigger_error>trigger_error</a> which invokes the default */
+and <a href=http://php.net/trigger_error>trigger_error</a> which invokes the default
PHP error handler.
<p>
Including the above file will cause <i>trigger_error($errorstring,E_USER_ERROR)</i>
<p>
If you want to log the error message, you can do so by defining the following optional
constants ADODB_ERROR_LOG_TYPE and ADODB_ERROR_LOG_DEST. ADODB_ERROR_LOG_TYPE is
- the error log message type (see <a href=http:/* php.net/error_log>error_log</a> */
+ the error log message type (see <a href=http://php.net/error_log>error_log</a>
in the PHP manual). In this case we set
it to 3, which means log to the file defined by the constant ADODB_ERROR_LOG_DEST.
<h2><a name="dsn"></a> Data Source Names</h2>
<p>We now support connecting using PEAR style DSN's. A DSN is a connection string
of the form:</p>
-<p>$dsn = <i>"$driver:/* $username:$password@$hostname/$databasename"</i>;</p> */
+<p>$dsn = <i>"$driver://$username:$password@$hostname/$databasename"</i>;</p>
<p>You pass the DSN to the static class function DB::Connect. An example:</p>
<pre> include_once('../adodb/adodb-pear.inc.php');
$username = 'root';
$hostname = 'localhost';
$databasename = 'xphplens';
$driver = 'mysql';
- $dsn = "$driver:/* $username:$password@$hostname/$databasename";</pre> */
+ $dsn = "$driver://$username:$password@$hostname/$databasename";</pre>
<pre> $db = DB::Connect($dsn);<br> $rs = $db->Execute('select firstname,lastname from adoxyz');
$cnt = 0;
while ($arr = $rs->FetchRow()) {
<pre> # $oraname in tnsnames.ora/ONAMES/HOSTNAMES
$conn->Connect(false, 'scott', 'tiger', $oraname);
$conn->Connect('server:1521', 'scott', 'tiger', 'ServiceName'); # bypass tnsnames.ora</pre>
-<p>There are many examples of connecting to a database at <a href="http:/* php.weblogs.com/adodb">php.weblogs.com/ADOdb</a>, */
+<p>There are many examples of connecting to a database at <a href="http://php.weblogs.com/adodb">php.weblogs.com/ADOdb</a>,
and in the testdatabases.inc.php file included in the release.</p>
<p><b>PConnect<a name="PConnect"></a>($host,[$user],[$password],[$database])</b></p>
<p>Persistent connect to data source or server $<b>host</b>, using userid $<b>user</b>
<p></p>
<p> Alternatively, since ADOdb 1.80, the $secs2cache parameter is optional:</p>
<pre> $conn->Connect(...);
- $conn->cacheSecs = 3600*24; /* cache 24 hours */
+ $conn->cacheSecs = 3600*24; // cache 24 hours
$rs = $conn->CacheExecute('select * from table');
</pre>
<p>If multiple calls to CacheExecute() are made and the recordset is still cached,
<p>Since 1.80, $secs2cache has been optional:</p>
</font>
<pre><font color="#000000"> $conn->Connect(...);
- $conn->cacheSecs = 3600*24; /* cache 24 hours */
+ $conn->cacheSecs = 3600*24; // cache 24 hours
$rs = $conn->CacheSelectLimit('select * from table',10);</font></pre>
<font color="#000000">
<p><b>CacheFlush<a name="CacheFlush"></a>($sql)</b></p>
If you want to flush all cached recordsets, execute the following PHP code (works
only under Unix): <code>system("rm -f `find ".ADODB_CACHE_DIR."
-name ADODB_*.cache`");</code></p>
-<p>For general cleanup of all expired files, you should use <a href="http:/* www.superscripts.com/tutorial/crontab.html">crontab</a> */
+<p>For general cleanup of all expired files, you should use <a href="http://www.superscripts.com/tutorial/crontab.html">crontab</a>
on Unix, or at.exe on Windows, and a shell script similar to the following:</p>
<p><font face="Courier New, Courier, mono">#------------------------------------------------------
<br>
[$<i><b>isOutput</b></i>] Indicates direction of parameter 0/false=IN 1=OUT
2= IN/OUT. This is ignored in oci8 as this driver auto-detects the direction.<br>
[$<b>maxLen</b>] Maximum length of the parameter variable.<br>
- [$<b>type</b>] Consult <a href="http:/* php.net/mssql_bind">mssql_bind</a> and <a href="http://php.net/ocibindbyname">ocibindbyname</a> */
+ [$<b>type</b>] Consult <a href="http://php.net/mssql_bind">mssql_bind</a> and <a href="http://php.net/ocibindbyname">ocibindbyname</a>
docs at php.net for more info on legal values for type.</p>
<p>In mssql, $opt can hold the following elements: array('type' => integer,
maxLen =>integer). Example:</p>
<p><b>ADOConnection Fields to Set</b></p>
<p>canSeek: Set to true if the _seek function works.</p>
<h2>ToDo:</h2>
-<p>See the <a href=http:/* php.weblogs.com/adodb-todo-roadmap>RoadMap</a> article.</p> */
-<p>Also see the ADOdb <a href=http:/* php.weblogs.com/adodb_csv>proxy</a> article */
+<p>See the <a href=http://php.weblogs.com/adodb-todo-roadmap>RoadMap</a> article.</p>
+<p>Also see the ADOdb <a href=http://php.weblogs.com/adodb_csv>proxy</a> article
for bridging Windows and Unix databases using http remote procedure calls. For
- your education, visit <a href=http:/* palslib.com/>palslib.com</a> for database info, */
+ your education, visit <a href=http://palslib.com/>palslib.com</a> for database info,
and read this article
- on <a href=http:/* phplens.com/lens/php-book/optimizing-debugging-php.php>Optimizing PHP</a>. */
+ on <a href=http://phplens.com/lens/php-book/optimizing-debugging-php.php>Optimizing PHP</a>.
</p>
</font>
<h2>Change Log<a name="Changes"></a><a name=ChangeLog></a></h2>
when supporting new ADODB_FETCH_MODEs.
<p>Mattia Rossi (mattia#technologist.com) contributed BlobDecode() and UpdateBlobFile() for postgresql
using the postgres specific pg_lo_import()/pg_lo_open() - i don't use them but hopefully others will
- find this useful. See <a href="http:/* phplens.com/lens/lensforum/msgs.php?id=1262">this posting</a> */
+ find this useful. See <a href="http://phplens.com/lens/lensforum/msgs.php?id=1262">this posting</a>
for an example of usage.
<p>Added UpdateBlobFile() for uploading files to a database.
<p>Made UpdateBlob() compatible with oci8po driver.
<p>Cached recordset timestamp not saved in some scenarios. Fixed.</p>
<p><b>1.10 19 May 2001</b></p>
<p>Added caching. CacheExecute() and CacheSelectLimit().
-<p>Added csv driver. See <a href="http:/* php.weblogs.com/adodb_csv">http://php.weblogs.com/ADODB_csv</a>. */
+<p>Added csv driver. See <a href="http://php.weblogs.com/adodb_csv">http://php.weblogs.com/ADODB_csv</a>.
<p>Fixed SelectLimit(), SELECT TOP not working under certain circumstances.
<p>Added better Frontbase support of MetaTypes() by Frank M. Kromann.
<p><b>1.01 24 April 2001</b></p>
* Connection parameters
*/
$driver = 'mysql';
-$host = 'localhost'; /* DSN for odbc */
+$host = 'localhost'; // DSN for odbc
$uid = 'root';
$pwd = '';
$database = 'northwind';
/*============================ DO NOT MODIFY BELOW HERE =================================*/
-/* $sep must match csv2rs() in adodb.inc.php */
+// $sep must match csv2rs() in adodb.inc.php
$sep = ' :::: ';
include('./adodb.inc.php');
die('**** '.$s.' ');
}
-/* undo stupid magic quotes */
+// undo stupid magic quotes
function undomq(&$m)
{
if (get_magic_quotes_gpc()) {
- /* undo the damage */
+ // undo the damage
$m = str_replace('\\\\','\\',$m);
$m = str_replace('\"','"',$m);
$m = str_replace('\\\'','\'',$m);
return $m;
}
-/* /////////////////////////////////////// DEFINITIONS */
+///////////////////////////////////////// DEFINITIONS
$remote = $HTTP_SERVER_VARS["REMOTE_ADDR"];
} else
$rs = $conn->Execute($sql);
if ($rs){
- /* $rs->timeToLive = 1; */
+ //$rs->timeToLive = 1;
echo _rs2serialize($rs,$conn,$sql);
$rs->Close();
} else
-<!DOCTYPE HTML PUBLIC "-/* W3C//DTD HTML 4.0 Transitional//EN"> */
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
It should not be used as proof of the superiority of one database over the other.
*/
-/* $testmssql = true; */
-/* $testvfp = true; */
+//$testmssql = true;
+//$testvfp = true;
$testoracle = true;
-/* $testado = true; */
-/* $testibase = true; */
+//$testado = true;
+//$testibase = true;
$testaccess = true;
$testmysql = true;
-set_time_limit(240); /* increase timeout */
+set_time_limit(240); // increase timeout
include("../tohtml.inc.php");
include("../adodb.inc.php");
print "<h3>ADODB Version: $ADODB_version Host: <i>$db->host</i> Database: <i>$db->database</i></h3>";
- /* perform query once to cache results so we are only testing throughput */
+ // perform query once to cache results so we are only testing throughput
$rs = $db->Execute($sql);
if (!$rs){
print "Error in recordset<p>";
return;
}
$arr = $rs->GetArray();
- /* $db->debug = true; */
+ //$db->debug = true;
$start = microtime();
for ($i=0; $i < $max; $i++) {
$rs = $db->Execute($sql);
$arr = $rs->GetArray();
- /* print $arr[0][1]; */
+ // print $arr[0][1];
}
$end = microtime();
$start = explode(' ',$start);
print_r($start);
print_r($end);
- /* print_r($arr); */
+ // print_r($arr);
$total = $end[0]+trim($end[1]) - $start[0]-trim($start[1]);
printf ("<p>seconds = %8.2f for %d iterations each with %d records</p>",$total,$max, sizeof($arr));
flush();
<table width=100% ><tr><td bgcolor=beige> </td></tr></table>
</p>
<?php
- /* $db->Close(); */
+ //$db->Close();
}
include("testdatabases.inc.php");
* set tabs to 8
*/
- /* documentation on usage is at http://php.weblogs.com/adodb_csv */
+ // documentation on usage is at http://php.weblogs.com/adodb_csv
include('../adodb.inc.php');
include('../tohtml.inc.php');
}
-$serverURL = 'http:/* localhost/php/phplens/adodb/server.php'; */
+$serverURL = 'http://localhost/php/phplens/adodb/server.php';
$testhttp = false;
$sql1 = "insertz into products (productname) values ('testprod 1')";
This script tests the following databases: Interbase, Oracle, Visual FoxPro, Microsoft Access (ODBC and ADO), MySQL, MSSQL (ODBC, native, ADO).
There is also support for Sybase, PostgreSQL.</p>
-For the latest version of ADODB, visit <a href=http:/* php.weblogs.com/ADODB>php.weblogs.com</a>.</p> */
+For the latest version of ADODB, visit <a href=http://php.weblogs.com/ADODB>php.weblogs.com</a>.</p>
<form method=get>
<input type=checkbox name=testaccess value=1 <?php echo !empty($testaccess) ? 'checked' : '' ?>> Access<br>
<?php
-/* Set the following control flags to true/false to enable testing for a particular database. */
+// Set the following control flags to true/false to enable testing for a particular database.
/*
$testoracle = true;
$testibase = true;
error_reporting(E_ALL);
-set_time_limit(240); /* increase timeout */
+set_time_limit(240); // increase timeout
include("../tohtml.inc.php");
include("../adodb.inc.php");
if ($ADODB_FETCH_MODE != ADODB_FETCH_DEFAULT) print "<h3>FETCH MODE IS NOT ADODB_FETCH_DEFAULT</h3>";
-/* the table creation code is specific to the database, so we allow the user */
-/* to define their own table creation stuff */
+// the table creation code is specific to the database, so we allow the user
+// to define their own table creation stuff
function testdb(&$db,$createtab="create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)")
{
GLOBAL $ADODB_vers,$ADODB_CACHE_DIR,$ADODB_FETCH_MODE, $HTTP_GET_VARS,$ADODB_COUNTRECS;
print "<br><i>ts3</i> (1970-1-2 +/- timezone) = ".$db->DBTimeStamp(24*3600);
$dd = $db->UnixDate('1999-02-20');
print "<br>unixdate</i> 1999-02-20 = ".date('Y-m-d',$dd)."<p>";
- /* mssql too slow in failing bad connection */
+ // mssql too slow in failing bad connection
if ($db->databaseType != 'mssql') {
print "<p>Testing bad connection. Ignore following error msgs:<br>";
$db2 = ADONewConnection();
}
error_reporting($e);
- /* $ADODB_COUNTRECS=false; */
+ //$ADODB_COUNTRECS=false;
$rs=$db->Execute('select * from adoxyz order by id');
- /* print_r($rs); */
- /* OCIFetchStatement($rs->_queryID,$rez,0,-1);//,OCI_ASSOC | OCI_FETCHSTATEMENT_BY_ROW); */
- /* print_r($rez); */
- /* die(); */
+ //print_r($rs);
+ //OCIFetchStatement($rs->_queryID,$rez,0,-1);//,OCI_ASSOC | OCI_FETCHSTATEMENT_BY_ROW);
+ //print_r($rez);
+ //die();
if($rs === false) $create = true;
else $rs->Close();
- /* if ($db->databaseType !='vfp') $db->Execute("drop table ADOXYZ"); */
+ //if ($db->databaseType !='vfp') $db->Execute("drop table ADOXYZ");
if ($create) {
if ($db->databaseType == 'ibase') {
}
}
- $rs = &$db->Execute("delete from ADOXYZ"); /* some ODBC drivers will fail the drop so we delete */
+ $rs = &$db->Execute("delete from ADOXYZ"); // some ODBC drivers will fail the drop so we delete
if ($rs) {
if(! $rs->EOF)print "<b>Error: </b>RecordSet returned by Execute('delete...') should show EOF</p>";
$rs->Close();
if ($rs) $rs->Close();
- /* $db->debug=true; */
+ //$db->debug=true;
print "<p>Testing Commit: ";
$time = $db->DBDate(time());
if (!$db->BeginTrans()) print '<b>Transactions not supported</b></p>';
$db->debug = false;
$ADODB_FETCH_MODE = ADODB_FETCH_BOTH;
- /* //////////////////////////////////////////////////////////////////////////////////////// */
+ //////////////////////////////////////////////////////////////////////////////////////////
$rs = &$db->Execute("select id,firstname as TheFirstName,lastname,created from ADOXYZ order by id");
if ($rs) {
$rs = &$db->Execute('select * from ADOXYZ');
if (empty($rs->connection)) print "<b>Connection object missing from recordset</b></br>";
- while ($o = $rs->FetchNextObject()) { /* calls FetchObject internally */
+ while ($o = $rs->FetchNextObject()) { // calls FetchObject internally
if (!is_string($o->FIRSTNAME) || !is_string($o->LASTNAME)) {
print_r($o);
print "<p><b>Firstname is not string</b></p>";
$rs = &$db->Execute('select * from ADOXYZ');
if (empty($rs->connection)) print "<b>Connection object missing from recordset</b></br>";
- while ($o = $rs->FetchNextObject()) { /* calls FetchObject internally */
+ while ($o = $rs->FetchNextObject()) { // calls FetchObject internally
if (!is_string($o->FIRSTNAME) || !is_string($o->LASTNAME)) {
print_r($o);
print "<p><b>Firstname is not string</b></p>";
if (trim($arr['firstname']) != 'Caroline') {print "<b>Error 2</b><br>"; print_r($arr);};
}
- /* $db->debug = true; */
+ //$db->debug = true;
print "<p>SelectLimit Test 1: Should see Caroline, John and Mary</p>";
$rs = &$db->SelectLimit('select distinct * from ADOXYZ order by id',3);
if ($rs && !$rs->EOF) {
if (trim($rs->fields[1]) != 'Mary') print "<b>Error 3</b><br>";
$rs->MoveNext();
if (! $rs->EOF) print "<b>Not EOF</b><br>";
- /* rs2html($rs); */
+ //rs2html($rs);
}
else "<p><b>Failed SelectLimit Test 1</b></p>";
print "<p>SelectLimit Test 2: Should see Mary, George and Mr. Alan</p>";
if (trim($rs->fields[1]) != 'Mr. Alan') print "<b>Error 3</b><br>";
$rs->MoveNext();
if (! $rs->EOF) print "<b>Not EOF</b><br>";
- /* rs2html($rs); */
+ // rs2html($rs);
}
else "<p><b>Failed SelectLimit Test 2</b></p>";
if (trim($rs->fields[1]) != 'Steven') print "<b>Error 2</b><br>";
$rs->MoveNext();
if (! $rs->EOF) print "<b>Not EOF</b><br>";
- /* rs2html($rs); */
+ //rs2html($rs);
}
else "<p><b>Failed SelectLimit Test 3</b></p>";
$db->debug = false;
}
else print "MoveFirst() OK<BR>";
- /* Move(3) tests error handling -- MoveFirst should not move cursor */
+ // Move(3) tests error handling -- MoveFirst should not move cursor
$rs->Move(3);
if (trim($rs->Fields("firstname")) != 'George') {
print '<p>'.$rs->Fields("id")."<b>$db->databaseType: Move(3) failed</b></p>";
}
}
- /* $db->debug=true; */
+ // $db->debug=true;
print "<p>Testing ADODB_FETCH_ASSOC and concat: concat firstname and lastname</p>";
$save = $ADODB_FETCH_MODE;
if ($val == 0) echo " <p><b>GenID not supported</b>";
echo "<p>";
- if (substr($db->dataProvider,0,3) != 'notused') { /* used to crash ado */
+ if (substr($db->dataProvider,0,3) != 'notused') { // used to crash ado
$sql = "select firstnames from adoxyz";
print "<p>Testing execution of illegal statement: <i>$sql</i></p>";
if ($db->Execute($sql) === false) {
} else {
print "<p><b>\$db->sysDate not defined</b></p>";
}
- /* PEAR TESTS BELOW */
+ // PEAR TESTS BELOW
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
$pear = true;
$rs = $db->query('select * from adoxyz order by id');
if ($rs && !$rs->EOF) {
while ($arr = $rs->fetchRow()) {
$i++;
- /* print "$i "; */
+ //print "$i ";
if ($arr[0] != $i) {
print "<p><b>PEAR DB emulation error 1.</b></p>";
$pear = false;
if ($ret != 1) print "<b>Replace failed: </b>";
print "test B return value=$ret (1 expected) <p>";
- /* /////////////////////////////////////////////////////////// */
+ /////////////////////////////////////////////////////////////
while (!is_object($rs->fetchInto($arr))) {
$i2++;
- /* print_r($arr); */
- /* print "$i ";print_r($arr); */
+ // print_r($arr);
+ // print "$i ";print_r($arr);
if ($arr[0] != $i2) {
print "<p><b>PEAR DB emulation error 2.</b></p>";
$pear = false;
-<!DOCTYPE HTML PUBLIC "-/* W3C//DTD HTML 4.0 Transitional//EN"> */
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
include('../adodb.inc.php');
include('../tohtml.inc.php');
-/* ========================== */
-/* This code tests an insert */
+//==========================
+// This code tests an insert
$sql = "SELECT * FROM ADOXYZ WHERE id = -1";
-/* Select an empty record from the database */
+// Select an empty record from the database
-$conn = &ADONewConnection("mysql"); /* create a connection */
+$conn = &ADONewConnection("mysql"); // create a connection
$conn->debug=1;
-$conn->PConnect("localhost", "root", "", "test"); /* connect to MySQL, testdb */
+$conn->PConnect("localhost", "root", "", "test"); // connect to MySQL, testdb
$conn->Execute("delete from adoxyz where lastname like 'Smith%'");
-$rs = $conn->Execute($sql); /* Execute the query and get the empty recordset */
-$record = array(); /* Initialize an array to hold the record data to insert */
+$rs = $conn->Execute($sql); // Execute the query and get the empty recordset
+$record = array(); // Initialize an array to hold the record data to insert
-/* Set the values for the fields in the record */
+// Set the values for the fields in the record
$record["firstname"] = "Bob";
-$record["lastname"] = "Smith\$@/* "; */
+$record["lastname"] = "Smith\$@//";
$record["created"] = time();
-/* Pass the empty recordset and the array containing the data to insert */
-/* into the GetInsertSQL function. The function will process the data and return */
-/* a fully formatted insert sql statement. */
+// Pass the empty recordset and the array containing the data to insert
+// into the GetInsertSQL function. The function will process the data and return
+// a fully formatted insert sql statement.
$insertSQL = $conn->GetInsertSQL($rs, $record);
-$conn->Execute($insertSQL); /* Insert the record into the database */
+$conn->Execute($insertSQL); // Insert the record into the database
-/* ========================== */
-/* This code tests an update */
+//==========================
+// This code tests an update
$sql = "SELECT * FROM ADOXYZ WHERE lastname=".$conn->qstr($record['lastname']);
-/* Select a record to update */
+// Select a record to update
-$rs = $conn->Execute($sql); /* Execute the query and get the existing record to update */
+$rs = $conn->Execute($sql); // Execute the query and get the existing record to update
if (!$rs) print "<p>No record found!</p>";
-$record = array(); /* Initialize an array to hold the record data to update */
+$record = array(); // Initialize an array to hold the record data to update
-/* Set the values for the fields in the record */
+// Set the values for the fields in the record
$record["firstname"] = "Caroline".rand();
-$record["lastname"] = "Smithy"; /* Update Caroline's lastname from Miranda to Smith */
+$record["lastname"] = "Smithy"; // Update Caroline's lastname from Miranda to Smith
$record["created"] = '2002-12-'.(rand()%30+1);
-/* Pass the single record recordset and the array containing the data to update */
-/* into the GetUpdateSQL function. The function will process the data and return */
-/* a fully formatted update sql statement. */
-/* If the data has not changed, no recordset is returned */
+// Pass the single record recordset and the array containing the data to update
+// into the GetUpdateSQL function. The function will process the data and return
+// a fully formatted update sql statement.
+// If the data has not changed, no recordset is returned
$updateSQL = $conn->GetUpdateSQL($rs, $record);
-$conn->Execute($updateSQL); /* Update the record in the database */
+$conn->Execute($updateSQL); // Update the record in the database
print "<p>Rows Affected=".$conn->Affected_Rows()."</p>";
rs2html($conn->Execute("select * from adoxyz where lastname like 'Smith%'"));
*/
-/* Select an empty record from the database */
+// Select an empty record from the database
include('../adodb.inc.php');
include('../tohtml.inc.php');
}
if (0) {
- $conn = &ADONewConnection("oci8"); /* create a connection */
+ $conn = &ADONewConnection("oci8"); // create a connection
$conn->debug=1;
- $conn->PConnect("falcon", "scott", "tiger", "juris8.ecosystem.natsoft.com.my"); /* connect to MySQL, testdb */
+ $conn->PConnect("falcon", "scott", "tiger", "juris8.ecosystem.natsoft.com.my"); // connect to MySQL, testdb
print $conn->databaseType.':'.$conn->GenID();
}
if (0) {
- $conn = &ADONewConnection("ibase"); /* create a connection */
+ $conn = &ADONewConnection("ibase"); // create a connection
$conn->debug=1;
- $conn->Connect("localhost:c:\\Interbase\\Examples\\Database\\employee.gdb", "sysdba", "masterkey", ""); /* connect to MySQL, testdb */
+ $conn->Connect("localhost:c:\\Interbase\\Examples\\Database\\employee.gdb", "sysdba", "masterkey", ""); // connect to MySQL, testdb
print $conn->databaseType.':'.$conn->GenID().'<br>';
}
/* this file is used by the ADODB test program: test.php */
-/* cannot test databases below, but we include them anyway to check */
-/* if they parse ok... */
+// cannot test databases below, but we include them anyway to check
+// if they parse ok...
ADOLoadCode("sybase");
ADOLoadCode("postgres");
ADOLoadCode("postgres7");
ADOLoadCode("sqlanywhere");
if (!empty($testpostgres)) {
- /* ADOLoadCode("postgres"); */
+ //ADOLoadCode("postgres");
$db = &ADONewConnection('postgres64');
print "<h1>Connecting $db->databaseType...</h1>";
if (@$db->PConnect("susetikus","tester","test","test")) {
}
-/* REQUIRES ODBC DSN CALLED nwind */
+// REQUIRES ODBC DSN CALLED nwind
if (!empty($testaccess)) {
$db = &ADONewConnection('access');
}
-if (!empty($testaccess) && !empty($testado)) { /* ADO ACCESS */
+if (!empty($testaccess) && !empty($testado)) { // ADO ACCESS
$db = &ADONewConnection("ado_access");
print "<h1>Connecting $db->databaseType...</h1>";
$access = 'd:\inetpub\wwwroot\php\NWIND.MDB';
$myDSN = 'PROVIDER=Microsoft.Jet.OLEDB.4.0;'
. 'DATA SOURCE=' . $access . ';';
- /* . 'USER ID=;PASSWORD=;'; */
+ //. 'USER ID=;PASSWORD=;';
if (@$db->PConnect($myDSN, "", "", "")) {
print "ADO version=".$db->_connectionID->version."<br>";
}
-if (!empty($testvfp)) { /* ODBC */
+if (!empty($testvfp)) { // ODBC
$db = &ADONewConnection('vfp');
}
-/* REQUIRES MySQL server at localhost with database 'test' */
-if (!empty($testmysql)) { /* MYSQL */
+// REQUIRES MySQL server at localhost with database 'test'
+if (!empty($testmysql)) { // MYSQL
$db = &ADONewConnection('maxsql');
print "<h1>Connecting $db->databaseType...</h1>";
print "<h1>Connecting $db->databaseType...</h1>";
if ($HTTP_SERVER_VARS['HTTP_HOST'] == 'localhost') $server = 'localhost';
- if ($db->PConnect('http:/* localhost/php/phplens/adodb/server.php')) */
+ if ($db->PConnect('http://localhost/php/phplens/adodb/server.php'))
testdb($db,
"create table ADOXYZ (id int, firstname char(24), lastname char(24), created date) type=innodb");
else print "ERROR: MySQL test requires a MySQL server on localhost, userid='admin', password='', database='test'".'<BR>'.$db->ErrorMsg();
$db = ADONewConnection('oci8po');
print "<h1>Connecting $db->databaseType...</h1>";
if ($db->Connect('', "scott", "tiger",'natsoft.ecosystem.natsoft.com.my'))
- /* if ($db->PConnect("", "scott", "tiger", "juris.ecosystem.natsoft.com.my")) */
+ //if ($db->PConnect("", "scott", "tiger", "juris.ecosystem.natsoft.com.my"))
testdb($db,"create table ADOXYZ (id int, firstname varchar(24), lastname varchar(24),created date)");
else print "ERROR: Oracle test requires an Oracle server setup with scott/tiger".'<BR>'.$db->ErrorMsg();
}
-ADOLoadCode("oracle"); /* no longer supported */
+ADOLoadCode("oracle"); // no longer supported
if (false && !empty($testoracle)) {
$db = ADONewConnection();
ADOLoadCode("odbc_mssql");
-if (!empty($testmssql) && false) { /* MS SQL Server via ODBC */
+if (!empty($testmssql) && false) { // MS SQL Server via ODBC
$db = ADONewConnection();
ADOLoadCode("ado_mssql");
-if (!empty($testmssql) && !empty($testado) ) { /* ADO ACCESS MSSQL -- thru ODBC -- DSN-less */
+if (!empty($testmssql) && !empty($testado) ) { // ADO ACCESS MSSQL -- thru ODBC -- DSN-less
$db = &ADONewConnection("ado_mssql");
$db->debug=1;
ADOLoadCode("mssql");
-if (!empty($testmssql)) { /* MS SQL Server -- the extension is buggy -- probably better to use ODBC */
+if (!empty($testmssql)) { // MS SQL Server -- the extension is buggy -- probably better to use ODBC
$db = ADONewConnection();
$db->debug=1;
print "<h1>Connecting $db->databaseType...</h1>";
}
-if (!empty($testmssql) && !empty($testado)) { /* ADO ACCESS MSSQL with OLEDB provider */
+if (!empty($testmssql) && !empty($testado)) { // ADO ACCESS MSSQL with OLEDB provider
$db = &ADONewConnection("ado_mssql");
print "<h1>Connecting DSN-less OLEDB Provider $db->databaseType...</h1>";
$db->debug=1;
$myDSN="SERVER=mangrove;DATABASE=ai;";
- /* $myDSN='SERVER=(local)\NetSDK;DATABASE=northwind;'; */
+ //$myDSN='SERVER=(local)\NetSDK;DATABASE=northwind;';
if ($db->PConnect($myDSN, "sa", "natsoft", 'SQLOLEDB'))
testdb($db,"create table ADOXYZ (id int, firstname char(24), lastname char(24),created datetime)");
else print "ERROR: MSSQL test 2 requires a MS SQL 7 on a server='mangrove', userid='sa', password='', database='ai'";
$table = 'adodbseq';
$db->Execute("drop table $table");
- /* $db->debug=true; */
+ //$db->debug=true;
$ctr = 5000;
$lastnum = 0;
include('../adodb.inc.php');
include('../tohtml.inc.php');
-/* ========================== */
-/* This code tests an insert */
+//==========================
+// This code tests an insert
-$conn = &ADONewConnection("odbc_mssql"); /* create a connection */
+$conn = &ADONewConnection("odbc_mssql"); // create a connection
$conn->Connect('sqlserver','sa','natsoft');
-/* $conn = &ADONewConnection("mssql"); */
-/* $conn->Connect('mangrove','sa','natsoft','ai'); */
+//$conn = &ADONewConnection("mssql");
+//$conn->Connect('mangrove','sa','natsoft','ai');
-/* $conn->Connect('mangrove','sa','natsoft','ai'); */
+//$conn->Connect('mangrove','sa','natsoft','ai');
$conn->debug=1;
$conn->Execute('delete from blobtest');
fwrite($fd, $rs->fields[0]);
fclose($fd);
-print " <a href=file:/* $output>View Image</a>"; */
-/* $rs = $conn->Execute('SELECT id,SUBSTRING(b1, 1, 10) FROM blobtest'); */
-/* rs2html($rs); */
+print " <a href=file://$output>View Image</a>";
+//$rs = $conn->Execute('SELECT id,SUBSTRING(b1, 1, 10) FROM blobtest');
+//rs2html($rs);
?>
\ No newline at end of file
if (!empty($testblob)) {
$varHoldingBlob = 'ABC DEF GEF John TEST';
$num = time()%10240;
- /* create table atable (id integer, ablob blob); */
+ // create table atable (id integer, ablob blob);
$db->Execute('insert into ATABLE (id,ablob) values('.$num.',empty_blob())');
$db->UpdateBlob('ATABLE', 'ablob', $varHoldingBlob, 'id='.$num, 'BLOB');
print $db->Affected_Rows().'<BR>';
$stmt = &$db->Prepare('insert into emp (empno, ename) values (:empno, :ename)');
$rs = $db->Execute($stmt,array('empno'=>4321,'ename'=>'John'));
- /* prepare not quite ready for prime time */
- /* $rs = $db->Execute($stmt,array('empno'=>3775,'ename'=>'John')); */
+ // prepare not quite ready for prime time
+ //$rs = $db->Execute($stmt,array('empno'=>3775,'ename'=>'John'));
if (!$rs) die("Empty RS");
}
$db->Connect('localhost','root','','xphplens');
}
-/* $db->pageExecuteCountRows = false; */
+//$db->pageExecuteCountRows = false;
$db->debug = true;
$pager = new ADODB_Pager($db,$sql);
-/* $pager->cache = 60; */
+//$pager->cache = 60;
$pager->Render($rows=7);
?>
\ No newline at end of file
$databasename = 'xphplens';
$driver = 'mysql';
-$dsn = "$driver:/* $username:$password@$hostname/$databasename"; */
+$dsn = "$driver://$username:$password@$hostname/$databasename";
$db = DB::Connect($dsn);
$db->setFetchMode(ADODB_FETCH_ASSOC);
-<!DOCTYPE HTML PUBLIC "-/* W3C//DTD HTML 4.0 Transitional//EN"> */
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
Dimension in my Mac days, to the databases I currently use, which are: Oracle,
FoxPro, Access, MS SQL Server and MySQL. Although most of the advice here applies
to using SQL with Perl, Python and other programming languages, I will focus on PHP and how
- the <a href="http:/* php.weblogs.com/adodb">ADOdb</a> database abstraction library */
+ the <a href="http://php.weblogs.com/adodb">ADOdb</a> database abstraction library
offers some solutions.<p></p>
<p>Most database vendors practice product lock-in. The best or fastest way to
do things is often implemented using proprietary extensions to SQL. This makes
sound principles. Learn the theory of normalization and entity-relationship diagrams and model
your data carefully. Understand how joins and indexes work and how they are used to tune performance.
<p> Visit the following page for more references on database theory and vendors:
- <a href="http:/* php.weblogs.com/sql_tutorial">http://php.weblogs.com/sql_tutorial</a>. */
- Also read this article on <a href=http:/* phplens.com/lens/php-book/optimizing-debugging-php.php>Optimizing PHP</a>. */
+ <a href="http://php.weblogs.com/sql_tutorial">http://php.weblogs.com/sql_tutorial</a>.
+ Also read this article on <a href=http://phplens.com/lens/php-book/optimizing-debugging-php.php>Optimizing PHP</a>.
<p>
<font size=1>(c) 2002 John Lim.</font>
* rscsvout($rs);
*/
-/* returns a recordset as a csv string */
+// returns a recordset as a csv string
function rs2csv(&$rs,$addtitles=true)
{
return _adodb_export($rs,',',',',false,$addtitles);
}
-/* writes recordset to csv file */
+// writes recordset to csv file
function rs2csvfile(&$rs,$fp,$addtitles=true)
{
_adodb_export($rs,',',',',$fp,$addtitles);
}
-/* write recordset as csv string to stdout */
+// write recordset as csv string to stdout
function rs2csvout(&$rs,$addtitles=true)
{
- $fp = fopen('php:/* stdout','wb'); */
+ $fp = fopen('php://stdout','wb');
_adodb_export($rs,',',',',true,$addtitles);
fclose($fp);
}
return _adodb_export($rs,"\t",',',false,$addtitles);
}
-/* to file pointer */
+// to file pointer
function tab2csvfile(&$rs,$fp,$addtitles=true)
{
_adodb_export($rs,"\t",',',$fp,$addtitles);
}
-/* to stdout */
+// to stdout
function tab2csvout(&$rs,$addtitles=true)
{
- $fp = fopen('php:/* stdout','wb'); */
+ $fp = fopen('php://stdout','wb');
_adodb_export($rs,"\t",' ',true,$addtitles);
fclose($fp);
}
function _adodb_export(&$rs,$sep,$sepreplace,$fp=false,$addtitles=true,$quote = '"',$escquote = '"',$replaceNewLine = ' ')
{
if (!$rs) return '';
- /* ---------- */
- /* CONSTANTS */
+ //----------
+ // CONSTANTS
$NEWLINE = "\r\n";
$BUFLINES = 100;
$escquotequote = $escquote.$quote;
if (strpos($v,$sep) || strpos($v,$quote))$elements[] = "$quote$v$quote";
else $elements[] = $v;
}
- } else { /* ASSOCIATIVE ARRAY */
+ } else { // ASSOCIATIVE ARRAY
foreach($rs->fields as $v) {
if ($escquote) $v = str_replace($quote,$escquotequote,$v);
$v = strip_tags(str_replace("\n",$replaceNewLine,str_replace($sep,$sepreplace,$v)));
Some pretty-printing by Chris Oxenreider <oxenreid@state.net>
*/
-/* specific code for tohtml */
+// specific code for tohtml
GLOBAL $gSQLMaxRows,$gSQLBlockRows;
-$gSQLMaxRows = 1000; /* max no of rows to download */
-$gSQLBlockRows=20; /* max no of rows per table block */
+$gSQLMaxRows = 1000; // max no of rows to download
+$gSQLBlockRows=20; // max no of rows per table block
-/* RecordSet to HTML Table */
-/* ------------------------------------------------------------ */
-/* Convert a recordset to a html table. Multiple tables are generated */
-/* if the number of rows is > $gSQLBlockRows. This is because */
-/* web browsers normally require the whole table to be downloaded */
-/* before it can be rendered, so we break the output into several */
-/* smaller faster rendering tables. */
-/* */
-/* $rs: the recordset */
-/* $ztabhtml: the table tag attributes (optional) */
-/* $zheaderarray: contains the replacement strings for the headers (optional) */
-/* */
-/* USAGE: */
-/* include('adodb.inc.php'); */
-/* $db = ADONewConnection('mysql'); */
-/* $db->Connect('mysql','userid','password','database'); */
-/* $rs = $db->Execute('select col1,col2,col3 from table'); */
-/* rs2html($rs, 'BORDER=2', array('Title1', 'Title2', 'Title3')); */
-/* $rs->Close(); */
-/* */
-/* RETURNS: number of rows displayed */
+// RecordSet to HTML Table
+//------------------------------------------------------------
+// Convert a recordset to a html table. Multiple tables are generated
+// if the number of rows is > $gSQLBlockRows. This is because
+// web browsers normally require the whole table to be downloaded
+// before it can be rendered, so we break the output into several
+// smaller faster rendering tables.
+//
+// $rs: the recordset
+// $ztabhtml: the table tag attributes (optional)
+// $zheaderarray: contains the replacement strings for the headers (optional)
+//
+// USAGE:
+// include('adodb.inc.php');
+// $db = ADONewConnection('mysql');
+// $db->Connect('mysql','userid','password','database');
+// $rs = $db->Execute('select col1,col2,col3 from table');
+// rs2html($rs, 'BORDER=2', array('Title1', 'Title2', 'Title3'));
+// $rs->Close();
+//
+// RETURNS: number of rows displayed
function rs2html(&$rs,$ztabhtml='',$zheaderarray="")
{
$s ='';$rows=0;$docnt = false;
}
if (! $ztabhtml) $ztabhtml = "BORDER='1' WIDTH='98%'";
- /* else $docnt = true; */
+ //else $docnt = true;
$typearr = array();
$ncols = $rs->FieldCount();
$hdr = "<TABLE COLS=$ncols $ztabhtml>\n\n";
if ($zheaderarray) $fname = $zheaderarray[$i];
else $fname = htmlspecialchars($field->name);
$typearr[$i] = $rs->MetaType($field->type,$field->max_length);
- /* print " $field->name $field->type $typearr[$i] "; */
+ //print " $field->name $field->type $typearr[$i] ";
if (empty($fname)) $fname = ' ';
$hdr .= "<TH>$fname</TH>";
print $hdr."\n\n";
- /* smart algorithm - handles ADODB_FETCH_MODE's correctly! */
+ // smart algorithm - handles ADODB_FETCH_MODE's correctly!
$numoffset = isset($rs->fields[0]);
while (!$rs->EOF) {
$s .= "<TR>\n";
$s = stripslashes($s);
$s = urldecode($s);
}
- } /* for */
+ } // for
$s .= "</TR>\n\n";
$rows += 1;
if ($rows >= $gSQLMaxRows) {
$rows = "<p>Truncated at $gSQLMaxRows</p>";
break;
- } /* switch */
+ } // switch
$rs->MoveNext();
- /* additional EOF check to prevent a widow header */
+ // additional EOF check to prevent a widow header
if (!$rs->EOF && $rows % $gSQLBlockRows == 0) {
- /* if (connection_aborted()) break;// not needed as PHP aborts script, unlike ASP */
+ //if (connection_aborted()) break;// not needed as PHP aborts script, unlike ASP
print $s . "</TABLE>\n\n";
$s = $hdr;
}
- } /* while */
+ } // while
print $s."</TABLE>\n\n";
{
if (!$ztabhtml) $ztabhtml = 'BORDER=1';
- $s = "<TABLE $ztabhtml>";/* ';print_r($arr); */
+ $s = "<TABLE $ztabhtml>";//';print_r($arr);
if ($zheaderarray) {
$s .= '<TR>';
-<!DOCTYPE HTML PUBLIC "-/* W3C//DTD HTML 4.0 Transitional//EN"> */
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<p>ADODB stands for Active Data Objects DataBase (sorry computer guys are sometimes
not very original). ADODB currently supports MySQL, PostgreSQL, Oracle, Interbase,
Microsoft SQL Server, Access, FoxPro, Sybase, ODBC and ADO. You can download
- ADODB from <a href=http:/* php.weblogs.com/adodb><a href="http://php.weblogs.com/adodb">http://php.weblogs.com/adodb</a></a>. */
+ ADODB from <a href=http://php.weblogs.com/adodb><a href="http://php.weblogs.com/adodb">http://php.weblogs.com/adodb</a></a>.
<h3>MySQL Example</h3>
<p>The most common database used with PHP is MySQL, so I guess you should be familiar
with the following code. It connects to a MySQL server at <i>localhost</i>,
$rs1 = $db->Execute('select * from table');
$<b>ADODB_FETCH_MODE</b> = ADODB_FETCH_ASSOC;
$rs2 = $db->Execute('select * from table');
- print_r($rs1->fields); /* shows <i>array([0]=>'v0',[1] =>'v1')</i> */
- print_r($rs2->fields); /* shows <i>array(['col1']=>'v0',['col2'] =>'v1')</i> */
+ print_r($rs1->fields); // shows <i>array([0]=>'v0',[1] =>'v1')</i>
+ print_r($rs2->fields); // shows <i>array(['col1']=>'v0',['col2'] =>'v1')</i>
</pre>
<p>
As you can see in the above example, both recordsets store and use different fetch modes
$conn->PConnect('localhost','userid','password','database');
$rs = $conn->Execute('select * from table');
<b> rs2html($rs)</b>; /* recordset to html table */ </pre>
-<p>There are many other helper functions that are listed in the documentation available at <a href="http:/* php.weblogs.com/adodb_manual"><a href="http://php.weblogs.com/adodb_manual">http://php.weblogs.com/adodb_manual</a></a>. */
+<p>There are many other helper functions that are listed in the documentation available at <a href="http://php.weblogs.com/adodb_manual"><a href="http://php.weblogs.com/adodb_manual">http://php.weblogs.com/adodb_manual</a></a>.
<h2>Advanced Material</h2>
<h3>Inserts and Updates </h3>
<p>Let's say you want to insert the following data into a database.
<p><b>PHP4 Session Handler Support</b>
<p>ADODB also supports PHP4 session handlers. You can store your session variables
in a database for true scalability using ADODB. For further information, visit
- <a href="http:/* php.weblogs.com/adodb-sessions"><a href="http://php.weblogs.com/adodb-sessions">http://php.weblogs.com/adodb-sessions</a></a> */
+ <a href="http://php.weblogs.com/adodb-sessions"><a href="http://php.weblogs.com/adodb-sessions">http://php.weblogs.com/adodb-sessions</a></a>
<h3>Commercial Use Encouraged</h3>
<p>If you plan to write commercial PHP applications that you want to resell, you should consider ADODB. It has been released using the lesser GPL, which means you can legally include it in commercial applications, while keeping your code proprietary. Commercial use of ADODB is strongly encouraged! We are using it internally for this reason.<p>