Problème lors de la mise ligne de mon site web [Résolu]

Messages postés
115
Date d'inscription
jeudi 26 mai 2005
Dernière intervention
8 septembre 2015
- 30 mai 2011 à 16:10 - Dernière réponse :
Messages postés
115
Date d'inscription
jeudi 26 mai 2005
Dernière intervention
8 septembre 2015
- 31 mai 2011 à 17:18
Bonjour à tous!
j'ai réalisé un site web en php4 avec des formulaires d'enregistrement(Base de donnée Mysql) qui marche correctement en local. Cependant lorsque je le met en ligne il ya un message d'erreur qui s'affiche :
Message d'erreur:
Fatal error: Call to undefined method tNG_fields::tNG_fields() in /home/xxxx/yyyyy/includes/tng/tNG_custom.class.php on line 19
je vous met le code d'un de mes formulaire et le fichier(tNG_custom.class.php). Merci de m'aider car je planche dessus depuis une semaine mais je n'ai aucune solution.
Formulaire d’insertion :




Administration












$NXT_FORM_SETTINGS = {
duplicate_buttons: false,
show_as_grid: false,
merge_down_value: false
}







,

----


----,
CREER / MODIFIER UN ARTICLE


----



Afficher la suite 

Votre réponse

10 réponses

Meilleure réponse
Messages postés
1660
Date d'inscription
dimanche 7 septembre 2008
Dernière intervention
11 septembre 2013
- 31 mai 2011 à 15:36
3
Merci
donc ta connection est ok
php 5.3
et ton script en php 4
là il y a un prob avec les variables
$http_post_var ... en php4 -> $_POST EN PHP5 ...
register_globals ... faut passer à 'on' en php5
car c'est désactivé pour des raisons de sécurité
en fait un gros travail de mise à jour

as tu
activer le rapport erreur php
en haut des fichiers à problemes
<?php
error_reporting(E_ALL);
ini_set('display_errors','On');
puis tu enleves si tout est resolu




Bonne programmation !

Merci cod57 3

Avec quelques mots c'est encore mieux Ajouter un commentaire

Codes Sources a aidé 90 internautes ce mois-ci

Commenter la réponse de cod57
Messages postés
1660
Date d'inscription
dimanche 7 septembre 2008
Dernière intervention
11 septembre 2013
- 30 mai 2011 à 20:41
0
Merci
bonjour

tNG_custom.class.php
appelle
parent::tNG_fields($connection);
y a t'il une $connection ?
quelle sont les valeurs de $connection
si c'est un array
dans
tNG_fields
surement que tu dois personnaliser des variables

a++


Bonne programmation !
Commenter la réponse de cod57
Messages postés
115
Date d'inscription
jeudi 26 mai 2005
Dernière intervention
8 septembre 2015
- 31 mai 2011 à 12:51
0
Merci
Effectivement j'ai un fichier de connexion. Ci-dessous le code de mon fichier servant a faire mes connexion.

[b]fichier:/b connect.php
<?php 
# PHP ADODB document - made with PHAkt
# FileName="Connection_php_adodb.htm"
# Type="ADODB"
# HTTP="true"
# DBTYPE="mysql"

$MM_connect_HOSTNAME = "localhost";
$MM_connect_DATABASE = "mysql:base_cpa";
$MM_connect_DBTYPE   = preg_replace("/:.*$/", "", $MM_connect_DATABASE);
$MM_connect_DATABASE = preg_replace("/^.*?:/", "", $MM_connect_DATABASE);
$MM_connect_USERNAME = "root";
$MM_connect_PASSWORD = "";
$MM_connect_LOCALE = "Fr";
$MM_connect_MSGLOCALE = "Fr";
$MM_connect_CTYPE = "P";
$KT_locale = $MM_connect_MSGLOCALE;
$KT_dlocale = $MM_connect_LOCALE;
$KT_serverFormat = "%Y-%m-%d %H:%M:%S";
$QUB_Caching = "false";

switch (strtoupper ($MM_connect_LOCALE)) {
case 'EN':
$KT_localFormat = "%d-%m-%Y %H:%M:%S";
break;
case 'EUS':
$KT_localFormat = "%m-%d-%Y %H:%M:%S";
break;
case 'FR':
$KT_localFormat = "%d-%m-%Y %H:%M:%S";
break;
case 'RO':
$KT_localFormat = "%d-%m-%Y %H:%M:%S";
break;
case 'IT':
$KT_localFormat = "%d-%m-%Y %H:%M:%S";
break;
case 'GE':
$KT_localFormat = "%d.%m.%Y %H:%M:%S";
break;
case 'US':
$KT_localFormat = "%Y-%m-%d %H:%M:%S";
break;
default :
$KT_localFormat = "none";			
}



if (!defined('CONN_DIR')) define('CONN_DIR',dirname(__FILE__));
require_once(CONN_DIR."/../adodb/adodb.inc.php");
ADOLoadCode($MM_connect_DBTYPE);
$connect=&ADONewConnection($MM_connect_DBTYPE);

if($MM_connect_DBTYPE "access" || $MM_connect_DBTYPE "odbc"){
if($MM_connect_CTYPE == "P"){
$connect->PConnect($MM_connect_DATABASE, $MM_connect_USERNAME,$MM_connect_PASSWORD, 
$MM_connect_LOCALE);
} else $connect->Connect($MM_connect_DATABASE, $MM_connect_USERNAME,$MM_connect_PASSWORD, 
$MM_connect_LOCALE);
} else if (($MM_connect_DBTYPE "ibase") or ($MM_connect_DBTYPE "firebird")) {
if($MM_connect_CTYPE == "P"){
$connect->PConnect($MM_connect_HOSTNAME.":".$MM_connect_DATABASE,$MM_connect_USERNAME,$MM_connect_PASSWORD);
} else $connect->Connect($MM_connect_HOSTNAME.":".$MM_connect_DATABASE,$MM_connect_USERNAME,$MM_connect_PASSWORD);
}else {
if($MM_connect_CTYPE == "P"){
$connect->PConnect($MM_connect_HOSTNAME,$MM_connect_USERNAME,$MM_connect_PASSWORD,
   			$MM_connect_DATABASE,$MM_connect_LOCALE);
} else $connect->Connect($MM_connect_HOSTNAME,$MM_connect_USERNAME,$MM_connect_PASSWORD,
   			$MM_connect_DATABASE,$MM_connect_LOCALE);
   }

if (!function_exists("updateMagicQuotes")) {
function updateMagicQuotes($HTTP_VARS){
if (is_array($HTTP_VARS)) {
foreach ($HTTP_VARS as $name=>$value) {
if (!is_array($value)) {
$HTTP_VARS[$name] = addslashes($value);
} else {
foreach ($value as $name1=>$value1) {
if (!is_array($value1)) {
$HTTP_VARS[$name1][$value1] = addslashes($value1);
}
}

}
global $$name;
$$name = &$HTTP_VARS[$name];
}
}
return $HTTP_VARS;
}

if (!get_magic_quotes_gpc()) {
$HTTP_GET_VARS = updateMagicQuotes($HTTP_GET_VARS);
$HTTP_POST_VARS = updateMagicQuotes($HTTP_POST_VARS);
$HTTP_COOKIE_VARS = updateMagicQuotes($HTTP_COOKIE_VARS);
}
}
if (!isset($HTTP_SERVER_VARS['REQUEST_URI'])) {
$HTTP_SERVER_VARS['REQUEST_URI'] = $HTTP_SERVER_VARS['PHP_SELF'];
}
?>
Commenter la réponse de massbbc
Messages postés
1660
Date d'inscription
dimanche 7 septembre 2008
Dernière intervention
11 septembre 2013
- 31 mai 2011 à 13:21
0
Merci
bonjour
il faut personnaliser ici
pour ton serveur distant
est il en php4 ou php5 ?
si il est en php5 un gros travail de mise à jour t'attend
sinon erreur sur erreur

$MM_connect_HOSTNAME = "localhost";/*non serveur distant*/
$MM_connect_DATABASE = "mysql:base_cpa";/*non base distante*/
$MM_connect_DBTYPE = preg_replace("/:.*$/", "", $MM_connect_DATABASE);
$MM_connect_DATABASE = preg_replace("/^.*?:/", "", $MM_connect_DATABASE);
$MM_connect_USERNAME = "root";/*login utilisateur*/
$MM_connect_PASSWORD = ""; /*mot de passe*/

a++
Bonne programmation !
Commenter la réponse de cod57
Messages postés
115
Date d'inscription
jeudi 26 mai 2005
Dernière intervention
8 septembre 2015
- 31 mai 2011 à 13:36
0
Merci
je ne sais pas ce que tu veux dire par personnaliser mais chez mon hébergeur voici les paramètre que j'ai mis:
$MM_connect_HOSTNAME = "localhost";
$MM_connect_DATABASE = "mysql:yyyy_dbxxx";
$MM_connect_DBTYPE   = preg_replace("/:.*$/", "", $MM_connect_DATABASE);
$MM_connect_DATABASE = preg_replace("/^.*?:/", "", $MM_connect_DATABASE);
$MM_connect_USERNAME = "username";
$MM_connect_PASSWORD = "passwd";


Est-ce qu'il faut changer le "localhost" ?
Commenter la réponse de massbbc
Messages postés
1660
Date d'inscription
dimanche 7 septembre 2008
Dernière intervention
11 septembre 2013
- 31 mai 2011 à 14:51
0
Merci
changer localhost ?
sans doute
faut voir qui est ton hebergeur
normalement tu as une adresse qu'il te fournit
ex chez free ex: sql.free.fr

je ferai un petit script
pour connaitre la version du serveur php
et l'état de la connection
test.php
<?php
$hostname="localhost"; /*ou ? ce que l'on t'a donné*/
$username="????"; /*ou ? ce que l'on t'a donné*/
$password="?????"; /*ou ? ce que l'on t'a donné*/
$db="ta_base"; /*ou ? ce que l'on t'a donné*/
/////////ne pas toucher plus bas//////////////////////
@$link=mysql_connect($hostname,$username,$password);
@$bdd=mysql_select_db($db,$link);

if($link){
echo 'accés serveur ok!!
';
}else{
echo 'accés serveur pas possible !
';
echo mysql_error().'
';
}
if($bdd){
echo 'accés base ok!!
';
}else{
echo 'accés base pas possible !
';
echo mysql_error().'
';
}
echo '
Serveur php version '.phpversion();
/*ou*/
phpinfo();
?>


Bonne programmation !
Commenter la réponse de cod57
Messages postés
115
Date d'inscription
jeudi 26 mai 2005
Dernière intervention
8 septembre 2015
- 31 mai 2011 à 15:17
0
Merci
J'ai fait le test sur mon serveur distant que tu m'a demandé et voici le résultat:

accés serveur ok!!
accés base ok!!
Serveur php version 5.3.1

je souligne que le localhost n'as pas été modifié je l'ai laissé com tel.
Je ne comprend donc plus ce ki se passe. J'ai demandé sur un foruùm et on m'a dis que le localhost ne change pas en général.
Merci pour ton aide
Commenter la réponse de massbbc
Messages postés
115
Date d'inscription
jeudi 26 mai 2005
Dernière intervention
8 septembre 2015
- 31 mai 2011 à 17:14
0
Merci
Comment passé à "on" sur en php 5.
jai mis le bout de code dans ma page accueil(index.php) et voici les erreurs que j'obtient:
[i]Deprecated: Assigning the return value of new by reference is deprecated in /home/xxxxx/public_html/adodb/adodb.inc.php on line 858

Deprecated: Assigning the return value of new by reference is deprecated in /home/xxxxx/public_html/adodb/adodb.inc.php on line 864

Deprecated: Assigning the return value of new by reference is deprecated in /home/xxxxx/public_html/adodb/adodb.inc.php on line 1171

Deprecated: Assigning the return value of new by reference is deprecated in /home/xxxxx/public_html/adodb/adodb.inc.php on line 1971

Deprecated: Assigning the return value of new by reference is deprecated in /home/xxxxx/public_html/adodb/adodb.inc.php on line 3033

Deprecated: Assigning the return value of new by reference is deprecated in /home/xxxxx/public_html/adodb/adodb.inc.php on line 3597

Deprecated: Assigning the return value of new by reference is deprecated in /home/xxxxx/public_html/adodb/adodb.inc.php on line 3671

Deprecated: Assigning the return value of new by reference is deprecated in /home/xxxxx/public_html/adodb/adodb.inc.php on line 3690

Fatal error: Call to undefined method tNG_fields::tNG_fields() in /home/xxxxx/public_html/includes/tng/tNG_custom.class.php on line 22/i
Commenter la réponse de massbbc
Messages postés
115
Date d'inscription
jeudi 26 mai 2005
Dernière intervention
8 septembre 2015
- 31 mai 2011 à 17:16
0
Merci
[b]ci-dessous le fichier:/b adodb.inc.php

[code=php]
Commenter la réponse de massbbc
Messages postés
115
Date d'inscription
jeudi 26 mai 2005
Dernière intervention
8 septembre 2015
- 31 mai 2011 à 17:18
0
Merci
Suite

[code=php]

function RollbackTrans()
{ return false;}


/**
* return the databases that the driver can connect to.
* Some databases will return an empty array.
*
* @return an array of database names.
*/
function MetaDatabases()
{
global $ADODB_FETCH_MODE;

if ($this->metaDatabasesSQL) {
$save = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;

if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);

$arr = $this->GetCol($this->metaDatabasesSQL);
if (isset($savem)) $this->SetFetchMode($savem);
$ADODB_FETCH_MODE = $save;

return $arr;
}

return false;
}

/**
* @param ttype can either be 'VIEW' or 'TABLE' or false.
* If false, both views and tables are returned.
* "VIEW" returns only views
* "TABLE" returns only tables
* @param showSchema returns the schema/user with the table name, eg. USER.TABLE
* @param mask is the input mask - only supported by oci8 and postgresql
*
* @return array of tables for current database.
*/
function &MetaTables($ttype=false,$showSchema=false,$mask=false)
{
global $ADODB_FETCH_MODE;

if ($mask) return false;

if ($this->metaTablesSQL) {
// complicated state saving by the need for backward compat
$save = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;

if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);

$rs = $this->Execute($this->metaTablesSQL);
if (isset($savem)) $this->SetFetchMode($savem);
$ADODB_FETCH_MODE = $save;

if ($rs === false) return false;
$arr =& $rs->GetArray();
$arr2 = array();

if ($hast = ($ttype && isset($arr[0][1]))) {
$showt = strncmp($ttype,'T',1);
}

for ($i=0; $i < sizeof($arr); $i++) {
if ($hast) {
if ($showt == 0) {
if (strncmp($arr[$i][1],'T',1) == 0) $arr2[] = trim($arr[$i][0]);
} else {
if (strncmp($arr[$i][1],'V',1) == 0) $arr2[] = trim($arr[$i][0]);
}
} else
$arr2[] = trim($arr[$i][0]);
}
$rs->Close();
return $arr2;
}
return false;
}


function _findschema(&$table,&$schema)
{
if (!$schema && ($at = strpos($table,'.')) !== false) {
$schema = substr($table,0,$at);
$table = substr($table,$at+1);
}
}

/**
* List columns in a database as an array of ADOFieldObjects.
* See top of file for definition of object.
*
* @param table table name to query
* @param upper uppercase table name (required by some databases)
* @schema is optional database schema to use - not supported by all databases.
*
* @return array of ADOFieldObjects for current table.
*/
function &MetaColumns($table,$upper=true)
{
global $ADODB_FETCH_MODE;

if (!empty($this->metaColumnsSQL)) {

$schema = false;
$this->_findschema($table,$schema);

$save = $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);
$rs = $this->Execute(sprintf($this->metaColumnsSQL,($upper)?strtoupper($table):$table));
if (isset($savem)) $this->SetFetchMode($savem);
$ADODB_FETCH_MODE = $save;
if ($rs === false) return false;

$retarr = array();
while (!$rs->EOF) { //print_r($rs->fields);
$fld =& new ADOFieldObject();
$fld->name = $rs->fields[0];
$fld->type = $rs->fields[1];
if (isset($rs->fields[3]) && $rs->fields[3]) {
if ($rs->fields[3]>0) $fld->max_length = $rs->fields[3];
$fld->scale = $rs->fields[4];
if ($fld->scale>0) $fld->max_length += 1;
} else
$fld->max_length = $rs->fields[2];

if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld;
else $retarr[strtoupper($fld->name)] = $fld;
$rs->MoveNext();
}
$rs->Close();
return $retarr;
}
return false;
}

/**
* List indexes on a table as an array.
* @param table table name to query
* @param primary include primary keys.
*
* @return array of indexes on current table.
*/
function &MetaIndexes($table, $primary = false, $owner = false)
{
return FALSE;
}

/**
* List columns names in a table as an array.
* @param table table name to query
*
* @return array of column names for current table.
*/
function &MetaColumnNames($table, $numIndexes=false)
{
$objarr =& $this->MetaColumns($table);
if (!is_array($objarr)) return false;

$arr = array();
if ($numIndexes) {
$i = 0;
foreach($objarr as $v) $arr[$i++] = $v->name;
} else
foreach($objarr as $v) $arr[strtoupper($v->name)] = $v->name;

return $arr;
}

/**
* Different SQL databases used different methods to combine strings together.
* This function provides a wrapper.
*
* param s variable number of string parameters
*
* Usage: $db->Concat($str1,$str2);
*
* @return concatenated string
*/
function Concat()
{
$arr = func_get_args();
return implode($this->concat_operator, $arr);
}


/**
* Converts a date "d" to a string that the database can understand.
*
* @param d a date in Unix date time format.
*
* @return date string in database date format
*/
function DBDate($d)
{
if (empty($d) && $d !== 0) return 'null';

if (is_string($d) && !is_numeric($d)) {
if ($d === 'null' || strncmp($d,"'",1) === 0) return $d;
if ($this->isoDates) return "'$d'";
$d = ADOConnection::UnixDate($d);
}

return adodb_date($this->fmtDate,$d);
}


/**
* Converts a timestamp "ts" to a string that the database can understand.
*
* @param ts a timestamp in Unix date time format.
*
* @return timestamp string in database timestamp format
*/
function DBTimeStamp($ts)
{
if (empty($ts) && $ts !== 0) return 'null';

# strlen(14) allows YYYYMMDDHHMMSS format
if (!is_string($ts) || (is_numeric($ts) && strlen($ts)fmtTimeStamp,$ts);

if ($ts === 'null') return $ts;
if ($this->isoDates && strlen($ts) !== 14) return "'$ts'";

$ts = ADOConnection::UnixTimeStamp($ts);
return adodb_date($this->fmtTimeStamp,$ts);
}

/**
* Also in ADORecordSet.
* @param $v is a date string in YYYY-MM-DD format
*
* @return date in unix timestamp format, or 0 if before TIMESTAMP_FIRST_YEAR, or false if invalid date format
*/
function UnixDate($v)
{
if (is_numeric($v) && strlen($v) !== 8) return $v;
if (!preg_match( "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})|",
($v), $rr)) return false;

if ($rr[1] emptyTimeStamp;
return ($gmt) ? adodb_gmdate($fmt,$tt) : adodb_date($fmt,$tt);
}

/**
* Quotes a string, without prefixing nor appending quotes.
*/
function addq($s,$magic_quotes=false)
{
if (!$magic_quotes) {

if ($this->replaceQuote[0] == '\\'){
// only since php 4.0.5
$s = adodb_str_replace(array('\\',"\0"),array('\\\\',"\\\0"),$s);
//$s = str_replace("\0","\\\0", str_replace('\\','\\\\',$s));
}
return str_replace("'",$this->replaceQuote,$s);
}

// undo magic quotes for "
$s = str_replace('\\"','"',$s);

if ($this->replaceQuote == "\\'") // ' already quoted, no need to change anything
return $s;
else {// change \' to '' for sybase/mssql
$s = str_replace('\\\\','\\',$s);
return str_replace("\\'",$this->replaceQuote,$s);
}
}

/**
* Correctly quotes a string so that all strings are escaped. We prefix and append
* to the string single-quotes.
* An example is $db->qstr("Don't bother",magic_quotes_runtime());
*
* @param s the string to quote
* @param [magic_quotes] if $s is GET/POST var, set to get_magic_quotes_gpc().
* This undoes the stupidity of magic quotes for GPC.
*
* @return quoted string to be sent back to database
*/
function qstr($s,$magic_quotes=false)
{
if (!$magic_quotes) {

if ($this->replaceQuote[0] == '\\'){
// only since php 4.0.5
$s = adodb_str_replace(array('\\',"\0"),array('\\\\',"\\\0"),$s);
//$s = str_replace("\0","\\\0", str_replace('\\','\\\\',$s));
}
return "'".str_replace("'",$this->replaceQuote,$s)."'";
}

// undo magic quotes for "
$s = str_replace('\\"','"',$s);

if ($this->replaceQuote == "\\'") // ' already quoted, no need to change anything
return "'$s'";
else {// change \' to '' for sybase/mssql
$s = str_replace('\\\\','\\',$s);
return "'".str_replace("\\'",$this->replaceQuote,$s)."'";
}
}


/**
* Will select the supplied $page number from a recordset, given that it is paginated in pages of
* $nrows rows per page. It also saves two boolean values saying if the given page is the first
* and/or last one of the recordset. Added by Iván Oliva to provide recordset pagination.
*
* See readme.htm#ex8 for an example of usage.
*
* @param sql
* @param nrows is the number of rows per page to get
* @param page is the page number to get (1-based)
* @param [inputarr] array of bind variables
* @param [secs2cache] is a private parameter only used by jlim
* @return the recordset ($rs->databaseType == 'array')
*
* NOTE: phpLens uses a different algorithm and does not use PageExecute().
*
*/
function &PageExecute($sql, $nrows, $page, $inputarr=false, $secs2cache=0)
{
global $ADODB_INCLUDED_LIB;
if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php');
if ($this->pageExecuteCountRows) $rs =& _adodb_pageexecute_all_rows($this, $sql, $nrows, $page, $inputarr, $secs2cache);
else $rs =& _adodb_pageexecute_no_last_page($this, $sql, $nrows, $page, $inputarr, $secs2cache);
return $rs;
}


/**
* Will select the supplied $page number from a recordset, given that it is paginated in pages of
* $nrows rows per page. It also saves two boolean values saying if the given page is the first
* and/or last one of the recordset. Added by Iván Oliva to provide recordset pagination.
*
* @param secs2cache seconds to cache data, set to 0 to force query
* @param sql
* @param nrows is the number of rows per page to get
* @param page is the page number to get (1-based)
* @param [inputarr] array of bind variables
* @return the recordset ($rs->databaseType == 'array')
*/
function &CachePageExecute($secs2cache, $sql, $nrows, $page,$inputarr=false)
{
/*switch($this->dataProvider) {
case 'postgres':
case 'mysql':
break;
default: $secs2cache = 0; break;
}*/
$rs =& $this->PageExecute($sql,$nrows,$page,$inputarr,$secs2cache);
return $rs;
}

} // end class ADOConnection



//==============================================================================================
// CLASS ADOFetchObj
//==============================================================================================

/**
* Internal placeholder for record objects. Used by ADORecordSet->FetchObj().
*/
class ADOFetchObj {
};

//==============================================================================================
// CLASS ADORecordSet_empty
//==============================================================================================

/**
* Lightweight recordset when there are no records to be returned
*/
class ADORecordSet_empty
{
var $dataProvider = 'empty';
var $databaseType = false;
var $EOF = true;
var $_numOfRows = 0;
var $fields = false;
var $connection = false;
function RowCount() {return 0;}
function RecordCount() {return 0;}
function PO_RecordCount(){return 0;}
function Close(){return true;}
function FetchRow() {return false;}
function FieldCount(){ return 0;}
function Init() {}
}

//==============================================================================================
// DATE AND TIME FUNCTIONS
//==============================================================================================
include_once(ADODB_DIR.'/adodb-time.inc.php');

//==============================================================================================
// CLASS ADORecordSet
//==============================================================================================

if (PHP_VERSION < 5) include_once(ADODB_DIR.'/adodb-php4.inc.php');
else include_once(ADODB_DIR.'/adodb-iterator.inc.php');
/**
* RecordSet class that represents the dataset returned by the database.
* To keep memory overhead low, this class holds only the current row in memory.
* No prefetching of data is done, so the RecordCount() can return -1 ( which
* means recordcount not known).
*/
class ADORecordSet extends ADODB_BASE_RS {
/*
* public variables
*/
var $dataProvider = "native";
var $fields = false; /// holds the current row data
var $blobSize = 100; /// any varchar/char field this size or greater is treated as a blob
/// in other words, we use a text area for editing.
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 $debug = false;
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
/*
* private variables
*/
var $_numOfRows = -1; /** number of rows, or -1 */
var $_numOfFields = -1; /** number of fields in recordset */
var $_queryID = -1; /** This variable keeps the result link identifier. */
var $_currentRow = -1; /** This variable keeps the current row in the Recordset. */
var $_closed = false; /** has recordset been closed */
var $_inited = false; /** Init() should only be called once */
var $_obj; /** Used by FetchObj */
var $_names; /** Used by FetchObj */

var $_currentPage = -1; /** Added by Iván Oliva to implement recordset pagination */
var $_atFirstPage = false; /** Added by Iván Oliva to implement recordset pagination */
var $_atLastPage = false; /** Added by Iván Oliva to implement recordset pagination */
var $_lastPageNo = -1;
var $_maxRecordCount = 0;
var $datetime = false;

/**
* Constructor
*
* @param queryID this is the queryID returned by ADOConnection->_query()
*
*/
function ADORecordSet($queryID)
{
$this->_queryID = $queryID;
}



function Init()
{
if ($this->_inited) return;
$this->_inited = true;
if ($this->_queryID) @$this->_initrs();
else {
$this->_numOfRows = 0;
$this->_numOfFields = 0;
}
if ($this->_numOfRows != 0 && $this->_numOfFields && $this->_currentRow == -1) {

$this->_currentRow = 0;
if ($this->EOF = ($this->_fetch() === false)) {
$this->_numOfRows = 0; // _numOfRows could be -1
}
} else {
$this->EOF = true;
}
}


/**
* Generate a SELECT tag string from a recordset, and return the string.
* If the recordset has 2 cols, we treat the 1st col as the containing
* the text to display to the user, and 2nd col as the return value. Default
* strings are compared with the FIRST column.
*
* @param name name of SELECT tag
* @param [defstr] the value to hilite. Use an array for multiple hilites for listbox.
* @param [blank1stItem] true to leave the 1st item in list empty
* @param [multiple] true for listbox, false for popup
* @param [size] #rows to show for listbox. not used by popup
* @param [selectAttr] additional attributes to defined for SELECT tag.
* useful for holding javascript onChange='...' handlers.
& @param [compareFields0] when we have 2 cols in recordset, we compare the defstr with
* column 0 (1st col) if this is true. This is not documented.
*
* @return HTML
*
* changes by glen.davies@cce.ac.nz to support multiple hilited items
*/
function GetMenu($name,$defstr='',$blank1stItem=true,$multiple=false,
$size=0, $selectAttr='',$compareFields0=true)
{
global $ADODB_INCLUDED_LIB;
if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php');
return _adodb_getmenu($this, $name,$defstr,$blank1stItem,$multiple,
$size, $selectAttr,$compareFields0);
}

/**
* Generate a SELECT tag string from a recordset, and return the string.
* If the recordset has 2 cols, we treat the 1st col as the containing
* the text to display to the user, and 2nd col as the return value. Default
* strings are compared with the SECOND column.
*
*/
function GetMenu2($name,$defstr='',$blank1stItem=true,$multiple=false,$size=0, $selectAttr='')
{
global $ADODB_INCLUDED_LIB;
if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php');
return _adodb_getmenu($this,$name,$defstr,$blank1stItem,$multiple,
$size, $selectAttr,false);
}


/**
* return recordset as a 2-dimensional array.
*
* @param [nRows] is the number of rows to return. -1 means every row.
*
* @return an array indexed by the rows (0-based) from the recordset
*/
function &GetArray($nRows = -1)
{
global $ADODB_EXTENSION; if ($ADODB_EXTENSION) return adodb_getall($this,$nRows);

$results = array();
$cnt = 0;
while (!$this->EOF && $nRows != $cnt) {
$results[] = $this->fields;
$this->MoveNext();
$cnt++;
}
return $results;
}

function &GetAll($nRows = -1)
{
$arr =& $this->GetArray($nRows);
return $arr;
}

/*
* Some databases allow multiple recordsets to be returned. This function
* will return true if there is a next recordset, or false if no more.
*/
function NextRecordSet()
{
return false;
}

/**
* return recordset as a 2-dimensional array.
* Helper function for ADOConnection->SelectLimit()
*
* @param offset is the row to start calculations from (1-based)
* @param [nrows] is the number of rows to return
*
* @return an array indexed by the rows (0-based) from the recordset
*/
function &GetArrayLimit($nrows,$offset=-1)
{
if ($offset GetArray($nrows);
return $arr;
}

$this->Move($offset);

$results = array();
$cnt = 0;
while (!$this->EOF && $nrows != $cnt) {
$results[$cnt++] = $this->fields;
$this->MoveNext();
}

return $results;
}


/**
* Synonym for GetArray() for compatibility with ADO.
*
* @param [nRows] is the number of rows to return. -1 means every row.
*
* @return an array indexed by the rows (0-based) from the recordset
*/
function &GetRows($nRows = -1)
{
$arr =& $this->GetArray($nRows);
return $arr;
}

/**
* return whole recordset as a 2-dimensional associative array if there are more than 2 columns.
* The first column is treated as the key and is not included in the array.
* If there is only 2 columns, it will return a 1 dimensional array of key-value pairs unless
* $force_array == true.
*
* @param [force_array] has only meaning if we have 2 data columns. If false, a 1 dimensional
* array is returned, otherwise a 2 dimensional array is returned. If this sounds confusing,
* read the source.
*
* @param [first2cols] means if there are more than 2 cols, ignore the remaining cols and
* instead of returning array[col0] => array(remaining cols), return array[col0] => col1
*
* @return an associative array indexed by the first column of the array,
* or false if the data has less than 2 cols.
*/
function &GetAssoc($force_array = false, $first2cols = false)
{
global $ADODB_EXTENSION;

$cols = $this->_numOfFields;
if ($cols < 2) {
return false;
}
$numIndex = isset($this->fields[0]);
$results = array();

if (!$first2cols && ($cols > 2 || $force_array)) {
if ($ADODB_EXTENSION) {
if ($numIndex) {
while (!$this->EOF) {
$results[trim($this->fields[0])] = array_slice($this->fields, 1);
adodb_movenext($this);
}
} else {
while (!$this->EOF) {
$results[trim(reset($this->fields))] = array_slice($this->fields, 1);
adodb_movenext($this);
}
}
} else {
if ($numIndex) {
while (!$this->EOF) {
$results[trim($this->fields[0])] = array_slice($this->fields, 1);
$this->MoveNext();
}
} else {
while (!$this->EOF) {
$results[trim(reset($this->fields))] = array_slice($this->fields, 1);
$this->MoveNext();
}
}
}
} else {
if ($ADODB_EXTENSION) {
// 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
$results[trim(($this->fields[0]))] = $this->fields[1];
adodb_movenext($this);
}
} else {
while (!$this->EOF) {
// 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;
adodb_movenext($this);
}
}
} else {
if ($numIndex) {
while (!$this->EOF) {
// 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
$v1 = trim(reset($this->fields));
$v2 = ''.next($this->fields);
$results[$v1] = $v2;
$this->MoveNext();
}
}
}
}
return $results;
}


/**
*
* @param v is the character timestamp in YYYY-MM-DD hh:mm:ss format
* @param fmt is the format to apply to it, using date()
*
* @return a timestamp formated as user desires
*/
function UserTimeStamp($v,$fmt='Y-m-d H:i:s')
{
if (is_numeric($v) && strlen($v)UnixTimeStamp($v);
// $tt == -1 if pre TIMESTAMP_FIRST_YEAR
if (($tt === false || $tt == -1) && $v != false) return $v;
if ($tt === 0) return $this->emptyTimeStamp;
return adodb_date($fmt,$tt);
}


/**
* @param v is the character date in YYYY-MM-DD format, returned by database
* @param fmt is the format to apply to it, using date()
*
* @return a date formated as user desires
*/
function UserDate($v,$fmt='Y-m-d')
{
$tt = $this->UnixDate($v);
// $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
}
return adodb_date($fmt,$tt);
}


/**
* @param $v is a date string in YYYY-MM-DD format
*
* @return date in unix timestamp format, or 0 if before TIMESTAMP_FIRST_YEAR, or false if invalid date format
*/
function UnixDate($v)
{
if (is_numeric($v) && strlen($v) !== 8) return $v;
if (!preg_match( "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})|",
($v), $rr)) return false;

if ($rr[1] 10000) return 0;

// h-m-s-MM-DD-YY
return @adodb_mktime(0,0,0,$rr[2],$rr[3],$rr[1]);
}


/**
* @param $v is a timestamp string in YYYY-MM-DD HH-NN-SS format
*
* @return date in unix timestamp format, or 0 if before TIMESTAMP_FIRST_YEAR, or false if invalid date format
*/
function UnixTimeStamp($v)
{

if (!preg_match(
"|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})[ ,-]*(([0-9]{1,2}):?([0-9]{1,2}):?([0-9\.]{1,4}))?|",
($v), $rr)) return false;
if ($rr[1] _numOfRows;
}


/**
* PEAR DB compat, number of cols
*/
function NumCols()
{
return $this->_numOfFields;
}

/**
* Fetch a row, returning false if no more rows.
* This is PEAR DB compat mode.
*
* @return false or array containing the current record
*/
function &FetchRow()
{
if ($this->EOF) return false;
$arr = $this->fields;
$this->_currentRow++;
if (!$this->_fetch()) $this->EOF = true;
return $arr;
}


/**
* Fetch a row, returning PEAR_Error if no more rows.
* This is PEAR DB compat mode.
*
* @return DB_OK or error object
*/
function FetchInto(&$arr)
{
if ($this->EOF) return (defined('PEAR_ERROR_RETURN')) ? new PEAR_Error('EOF',-1): false;
$arr = $this->fields;
$this->MoveNext();
return 1; // DB_OK
}


/**
* Move to the first row in the recordset. Many databases do NOT support this.
*
* @return true or false
*/
function MoveFirst()
{
if ($this->_currentRow == 0) return true;
return $this->Move(0);
}


/**
* Move to the last row in the recordset.
*
* @return true or false
*/
function MoveLast()
{
if ($this->_numOfRows >= 0) return $this->Move($this->_numOfRows-1);
if ($this->EOF) return false;
while (!$this->EOF) {
$f = $this->fields;
$this->MoveNext();
}
$this->fields = $f;
$this->EOF = false;
return true;
}


/**
* Move to next record in the recordset.
*
* @return true if there still rows available, or false if there are no more rows (EOF).
*/
function MoveNext()
{
if (!$this->EOF) {
$this->_currentRow++;
if ($this->_fetch()) return true;
}
$this->EOF = true;
/* -- tested error handling when scrolling cursor -- seems useless.
$conn = $this->connection;
if ($conn && $conn->raiseErrorFn && ($errno = $conn->ErrorNo())) {
$fn = $conn->raiseErrorFn;
$fn($conn->databaseType,'MOVENEXT',$errno,$conn->ErrorMsg().' ('.$this->sql.')',$conn->host,$conn->database);
}
*/
return false;
}


/**
* Random access to a specific row in the recordset. Some databases do not support
* access to previous rows in the databases (no scrolling backwards).
*
* @param rowNumber is the row to move to (0-based)
*
* @return true if there still rows available, or false if there are no more rows (EOF).
*/
function Move($rowNumber = 0)
{
$this->EOF = false;
if ($rowNumber == $this->_currentRow) return true;
if ($rowNumber >= $this->_numOfRows)
if ($this->_numOfRows != -1) $rowNumber = $this->_numOfRows-2;

if ($this->canSeek) {

if ($this->_seek($rowNumber)) {
$this->_currentRow = $rowNumber;
if ($this->_fetch()) {
return true;
}
} else {
$this->EOF = true;
return false;
}
} else {
if ($rowNumber < $this->_currentRow) return false;
global $ADODB_EXTENSION;
if ($ADODB_EXTENSION) {
while (!$this->EOF && $this->_currentRow < $rowNumber) {
adodb_movenext($this);
}
} else {

while (! $this->EOF && $this->_currentRow < $rowNumber) {
$this->_currentRow++;

if (!$this->_fetch()) $this->EOF = true;
}
}
return !($this->EOF);
}

$this->fields = false;
$this->EOF = true;
return false;
}


/**
* Get the value of a field in the current row by column name.
* Will not work if ADODB_FETCH_MODE is set to ADODB_FETCH_NUM.
*
* @param colname is the field to access
*
* @return the value of $colname column
*/
function Fields($colname)
{
return $this->fields[$colname];
}

function GetAssocKeys($upper=true)
{
$this->bind = array();
for ($i=0; $i < $this->_numOfFields; $i++) {
$o =& $this->FetchField($i);
if ($upper === 2) $this->bind[$o->name] = $i;
else $this->bind[($upper) ? strtoupper($o->name) : strtolower($o->name)] = $i;
}
}

/**
* Use associative array to get fields array for databases that do not support
* associative arrays. Submitted by Paolo S. Asioli paolo.asioli#libero.it
*
* If you don't want uppercase cols, set $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC
* before you execute your SQL statement, and access $rs->fields['col'] directly.
*
* $upper 0 = lowercase, 1 = uppercase, 2 = whatever is returned by FetchField
*/
function &GetRowAssoc($upper=1)
{
$record = array();
// if (!$this->fields) return $record;

if (!$this->bind) {
$this->GetAssocKeys($upper);
}

foreach($this->bind as $k => $v) {
$record[$k] = $this->fields[$v];
}

return $record;
}


/**
* Clean up recordset
*
* @return true or false
*/
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;
if (!$this->_closed) {
$this->_closed = true;
return $this->_close();
} else
return true;
}

/**
* synonyms RecordCount and RowCount
*
* @return the number of rows or -1 if this is not supported
*/
function RecordCount() {return $this->_numOfRows;}


/*
* If we are using PageExecute(), this will return the maximum possible rows
* that can be returned when paging a recordset.
*/
function MaxRecordCount()
{
return ($this->_maxRecordCount) ? $this->_maxRecordCount : $this->RecordCount();
}

/**
* synonyms RecordCount and RowCount
*
* @return the number of rows or -1 if this is not supported
*/
function RowCount() {return $this->_numOfRows;}


/**
* Portable RecordCount. Pablo Roca
*
* @return the number of records from a previous SELECT. All databases support this.
*
* But aware possible problems in multiuser environments. For better speed the table
* must be indexed by the condition. Heavy test this before deploying.
*/
function PO_RecordCount($table="", $condition="") {

$lnumrows = $this->_numOfRows;
// the database doesn't support native recordcount, so we do a workaround
if ($lnumrows == -1 && $this->connection) {
IF ($table) {
if ($condition) $condition = " WHERE " . $condition;
$resultrows = &$this->connection->Execute("SELECT COUNT(*) FROM $table $condition");
if ($resultrows) $lnumrows = reset($resultrows->fields);
}
}
return $lnumrows;
}

/**
* @return the current row in the recordset. If at EOF, will return the last row. 0-based.
*/
function CurrentRow() {return $this->_currentRow;}

/**
* synonym for CurrentRow -- for ADO compat
*
* @return the current row in the recordset. If at EOF, will return the last row. 0-based.
*/
function AbsolutePosition() {return $this->_currentRow;}

/**
* @return the number of columns in the recordset. Some databases will set this to 0
* if no records are returned, others will return the number of columns in the query.
*/
function FieldCount() {return $this->_numOfFields;}


/**
* Get the ADOFieldObject of a specific column.
*
* @param fieldoffset is the column position to access(0-based).
*
* @return the ADOFieldObject for that column, or false.
*/
function &FetchField($fieldoffset)
{
// must be defined by child class
}

/**
* Get the ADOFieldObjects of all columns in an array.
*
*/
function& FieldTypesArray()
{
$arr = array();
for ($i=0, $max=$this->_numOfFields; $i < $max; $i++)
$arr[] = $this->FetchField($i);
return $arr;
}

/**
* Return the fields array of the current row as an object for convenience.
* The default case is lowercase field names.
*
* @return the object with the properties set to the fields of the current row
*/
function &FetchObj()
{
$o =& $this->FetchObject(false);
return $o;
}

/**
* Return the fields array of the current row as an object for convenience.
* The default case is uppercase.
*
* @param $isupper to set the object property names to uppercase
*
* @return the object with the properties set to the fields of the current row
*/
function &FetchObject($isupper=true)
{
if (empty($this->_obj)) {
$this->_obj =& new ADOFetchObj();
$this->_names = array();
for ($i=0; $i _numOfFields; $i++) {
$f = $this->FetchField($i);
$this->_names[] = $f->name;
}
}
$i = 0;
$o = &$this->_obj;
for ($i=0; $i _numOfFields; $i++) {
$name = $this->_names[$i];
if ($isupper) $n = strtoupper($name);
else $n = $name;

$o->$n = $this->Fields($name);
}
return $o;
}

/**
* Return the fields array of the current row as an object for convenience.
* The default is lower-case field names.
*
* @return the object with the properties set to the fields of the current row,
* or false if EOF
*
* Fixed bug reported by tim@orotech.net
*/
function &FetchNextObj()
{
$o = $this->FetchNextObject(false);
return $o;
}


/**
* Return the fields array of the current row as an object for convenience.
* The default is upper case field names.
*
* @param $isupper to set the object property names to uppercase
*
* @return the object with the properties set to the fields of the current row,
* or false if EOF
*
* Fixed bug reported by tim@orotech.net
*/
function &FetchNextObject($isupper=true)
{
$o = false;
if ($this->_numOfRows != 0 && !$this->EOF) {
$o = $this->FetchObject($isupper);
$this->_currentRow++;
if ($this->_fetch()) return $o;
}
$this->EOF = true;
return $o;
}

/**
* Get the metatype of the column. This is used for formatting. This is because
* many databases use different names for the same type, so we transform the original
* type to our standardised version which uses 1 character codes:
*
* @param t is the type passed in. Normally is ADOFieldObject->type.
* @param len is the maximum length of that field. This is because we treat character
* fields bigger than a certain size as a 'B' (blob).
* @param fieldobj is the field object returned by the database driver. Can hold
* additional info (eg. primary_key for mysql).
*
* @return the general type of the data:
* C for character < 250 chars
* X for teXt (>= 250 chars)
* B for Binary
* N for numeric or floating point
* D for date
* T for timestamp
* L for logical/Boolean
* I for integer
* R for autoincrement counter/integer
*
*
*/
function MetaType($t,$len=-1,$fieldobj=false)
{
if (is_object($t)) {
$fieldobj = $t;
$t = $fieldobj->type;
$len = $fieldobj->max_length;
}
// changed in 2.32 to hashing instead of switch stmt for speed...
static $typeMap = array(
'VARCHAR' => 'C',
'VARCHAR2' => 'C',
'CHAR' => 'C',
'C' => 'C',
'STRING' => 'C',
'NCHAR' => 'C',
'NVARCHAR' => 'C',
'VARYING' => 'C',
'BPCHAR' => 'C',
'CHARACTER' => 'C',
'INTERVAL' => 'C', # Postgres
##
'LONGCHAR' => 'X',
'TEXT' => 'X',
'NTEXT' => 'X',
'M' => 'X',
'X' => 'X',
'CLOB' => 'X',
'NCLOB' => 'X',
'LVARCHAR' => 'X',
##
'BLOB' => 'B',
'IMAGE' => 'B',
'BINARY' => 'B',
'VARBINARY' => 'B',
'LONGBINARY' => 'B',
'B' => 'B',
##
'YEAR' => 'D', // mysql
'DATE' => 'D',
'D' => 'D',
##
'TIME' => 'T',
'TIMESTAMP' => 'T',
'DATETIME' => 'T',
'TIMESTAMPTZ' => 'T',
'T' => 'T',
##
'BOOL' => 'L',
'BOOLEAN' => 'L',
'BIT' => 'L',
'L' => 'L',
##
'COUNTER' => 'R',
'R' => 'R',
'SERIAL' => 'R', // ifx
'INT IDENTITY' => 'R',
##
'INT' => 'I',
'INTEGER' => 'I',
'INTEGER UNSIGNED' => 'I',
'SHORT' => 'I',
'TINYINT' => 'I',
'SMALLINT' => 'I',
'I' => 'I',
##
'LONG' => 'N', // interbase is numeric, oci8 is blob
'BIGINT' => 'N', // this is bigger than PHP 32-bit integers
'DECIMAL' => 'N',
'DEC' => 'N',
'REAL' => 'N',
'DOUBLE' => 'N',
'DOUBLE PRECISION' => 'N',
'SMALLFLOAT' => 'N',
'FLOAT' => 'N',
'NUMBER' => 'N',
'NUM' => 'N',
'NUMERIC' => 'N',
'MONEY' => 'N',

## informix 9.2
'SQLINT' => 'I',
'SQLSERIAL' => 'I',
'SQLSMINT' => 'I',
'SQLSMFLOAT' => 'N',
'SQLFLOAT' => 'N',
'SQLMONEY' => 'N',
'SQLDECIMAL' => 'N',
'SQLDATE' => 'D',
'SQLVCHAR' => 'C',
'SQLCHAR' => 'C',
'SQLDTIME' => 'T',
'SQLINTERVAL' => 'N',
'SQLBYTES' => 'B',
'SQLTEXT' => 'X'
);

$tmap = false;
$t = strtoupper($t);
$tmap = @$typeMap[$t];
switch ($tmap) {
case 'C':

// is the char field is too long, return as text field...
if ($this->blobSize >= 0) {
if ($len > $this->blobSize) return 'X';
} else if ($len > 250) {
return 'X';
}
return 'C';

case 'I':
if (!empty($fieldobj->primary_key)) return 'R';
return 'I';

case false:
return 'N';

case 'B':
if (isset($fieldobj->binary))
return ($fieldobj->binary) ? 'B' : 'X';
return 'B';

case 'D':
if (!empty($this->datetime)) return 'T';
return 'D';

default:
if ($t == 'LONG' && $this->dataProvider == 'oci8') return 'B';
return $tmap;
}
}

function _close() {}

/**
* set/returns the current recordset page when paginating
*/
function AbsolutePage($page=-1)
{
if ($page != -1) $this->_currentPage = $page;
return $this->_currentPage;
}

/**
* set/returns the status of the atFirstPage flag when paginating
*/
function AtFirstPage($status=false)
{
if ($status != false) $this->_atFirstPage = $status;
return $this->_atFirstPage;
}

function LastPageNo($page = false)
{
if ($page != false) $this->_lastPageNo = $page;
return $this->_lastPageNo;
}

/**
* set/returns the status of the atLastPage flag when paginating
*/
function AtLastPage($status=false)
{
if ($status != false) $this->_atLastPage = $status;
return $this->_atLastPage;
}

} // end class ADORecordSet

//==============================================================================================
// CLASS ADORecordSet_array
//==============================================================================================

/**
* This class encapsulates the concept of a recordset created in memory
* as an array. This is useful for the creation of cached recordsets.
*
* Note that the constructor is different from the standard ADORecordSet
*/

class ADORecordSet_array extends ADORecordSet
{
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 $canSeek = true;
var $affectedrows = false;
var $insertid = false;
var $sql = '';
var $compat = false;
/**
* Constructor
*
*/
function ADORecordSet_array($fakeid=1)
{
global $ADODB_FETCH_MODE,$ADODB_COMPAT_FETCH;

// fetch() on EOF does not delete $this->fields
$this->compat = !empty($ADODB_COMPAT_FETCH);
$this->ADORecordSet($fakeid); // fake queryID
$this->fetchMode = $ADODB_FETCH_MODE;
}


/**
* Setup the array.
*
* @param array is a 2-dimensional array holding the data.
* The first row should hold the column names
* unless paramter $colnames is used.
* @param typearr holds an array of types. These are the same types
* used in MetaTypes (C,B,L,I,N).
* @param [colnames] array of column names. If set, then the first row of
* $array should not hold the column names.
*/
function InitArray($array,$typearr,$colnames=false)
{
$this->_array = $array;
$this->_types = $typearr;
if ($colnames) {
$this->_skiprow1 = false;
$this->_colnames = $colnames;
} else {
$this->_skiprow1 = true;
$this->_colnames = $array[0];
}
$this->Init();
}
/**
* Setup the Array and datatype file objects
*
* @param array is a 2-dimensional array holding the data.
* The first row should hold the column names
* unless paramter $colnames is used.
* @param fieldarr holds an array of ADOFieldObject's.
*/
function InitArrayFields(&$array,&$fieldarr)
{
$this->_array =& $array;
$this->_skiprow1= false;
if ($fieldarr) {
$this->_fieldobjects =& $fieldarr;
}
$this->Init();
}

function &GetArray($nRows=-1)
{
if ($nRows == -1 && $this->_currentRow _skiprow1) {
return $this->_array;
} else {
$arr =& ADORecordSet::GetArray($nRows);
return $arr;
}
}

function _initrs()
{
$this->_numOfRows = sizeof($this->_array);
if ($this->_skiprow1) $this->_numOfRows -= 1;

$this->_numOfFields =(isset($this->_fieldobjects)) ?
sizeof($this->_fieldobjects):sizeof($this->_types);
}

/* Use associative array to get fields array */
function Fields($colname)
{
if ($this->fetchMode & ADODB_FETCH_ASSOC) {
if (!isset($this->fields[$colname])) $colname = strtolower($colname);
return $this->fields[$colname];
}
if (!$this->bind) {
$this->bind = array();
for ($i=0; $i < $this->_numOfFields; $i++) {
$o = $this->FetchField($i);
$this->bind[strtoupper($o->name)] = $i;
}
}
return $this->fields[$this->bind[strtoupper($colname)]];
}

function &FetchField($fieldOffset = -1)
{
if (isset($this->_fieldobjects)) {
return $this->_fieldobjects[$fieldOffset];
}
$o = new ADOFieldObject();
$o->name = $this->_colnames[$fieldOffset];
$o->type = $this->_types[$fieldOffset];
$o->max_length = -1; // length not known

return $o;
}

function _seek($row)
{
if (sizeof($this->_array) && 0 _numOfRows) {
$this->_currentRow = $row;
if ($this->_skiprow1) $row += 1;
$this->fields = $this->_array[$row];
return true;
}
return false;
}

function MoveNext()
{
if (!$this->EOF) {
$this->_currentRow++;

$pos = $this->_currentRow;

if ($this->_numOfRows compat) $this->fields = false;
} else {
if ($this->_skiprow1) $pos += 1;
$this->fields = $this->_array[$pos];
return true;
}
$this->EOF = true;
}

return false;
}

function _fetch()
{
$pos = $this->_currentRow;

if ($this->_numOfRows compat) $this->fields = false;
return false;
}
if ($this->_skiprow1) $pos += 1;
$this->fields = $this->_array[$pos];
return true;
}

function _close()
{
return true;
}

} // ADORecordSet_array

//==============================================================================================
// HELPER FUNCTIONS
//==============================================================================================

/**
* Synonym for ADOLoadCode. Private function. Do not use.
*
* @deprecated
*/
function ADOLoadDB($dbType)
{
return ADOLoadCode($dbType);
}

/**
* Load the code for a specific database driver. Private function. Do not use.
*/
function ADOLoadCode($dbType)
{
global $ADODB_LASTDB;

if (!$dbType) return false;
$db = strtolower($dbType);
switch ($db) {
case 'ifx':
case 'maxsql': $db = 'mysqlt'; break;
case 'postgres':
case 'pgsql': $db = 'postgres7'; break;
}
@include_once(ADODB_DIR."/drivers/adodb-".$db.".inc.php");
$ADODB_LASTDB = $db;

$ok = class_exists("ADODB_" . $db);
if ($ok) return $db;

print_r(get_declared_classes());
$file = ADODB_DIR."/drivers/adodb-".$db.".inc.php";
if (!file_exists($file)) ADOConnection::outp("Missing file: $file");
else ADOConnection::outp("Syntax error in file: $file");
return false;
}

/**
* synonym for ADONewConnection for people like me who cannot remember the correct name
*/
function &NewADOConnection($db='')
{
$tmp =& ADONewConnection($db);
return $tmp;
}

/**
* Instantiate a new Connection class for a specific database driver.
*
* @param [db] is the database Connection object to create. If undefined,
* use the last database driver that was loaded by ADOLoadCode().
*
* @return the freshly created instance of the Connection class.
*/
function &ADONewConnection($db='')
{
GLOBAL $ADODB_NEWCONNECTION, $ADODB_LASTDB;

if (!defined('ADODB_ASSOC_CASE')) define('ADODB_ASSOC_CASE',2);
$errorfn = (defined('ADODB_ERROR_HANDLER')) ? ADODB_ERROR_HANDLER : false;

if (strpos($db,'://')) {
$origdsn = $db;
$dsna = @parse_url($db);
if (!$dsna) {
// special handling of oracle, which might not have host
$db = str_replace('@/','@adodb-fakehost/',$db);
$dsna = parse_url($db);
if (!$dsna) return false;
$dsna['host'] = '';
}
$db = @$dsna['scheme'];
if (!$db) return false;
$dsna['host'] = isset($dsna['host']) ? rawurldecode($dsna['host']) : '';
$dsna['user'] = isset($dsna['user']) ? rawurldecode($dsna['user']) : '';
$dsna['pass'] = isset($dsna['pass']) ? rawurldecode($dsna['pass']) : '';
$dsna['path'] = isset($dsna['path']) ? rawurldecode(substr($dsna['path'],1)) : '';

if (isset($dsna['query'])) {
$opt1 = explode('&',$dsna['query']);
foreach($opt1 as $k => $v) {
$arr = explode('=',$v);
$opt[$arr[0]] = isset($arr[1]) ? rawurldecode($arr[1]) : 1;
}
} else $opt = array();
}

/*
* phptype: Database backend used in PHP (mysql, odbc etc.)
* dbsyntax: Database used with regards to SQL syntax etc.
* protocol: Communication protocol to use (tcp, unix etc.)
* hostspec: Host specification (hostname[:port])
* database: Database to use on the DBMS server
* username: User name for login
* password: Password for login
*/
if (!empty($ADODB_NEWCONNECTION)) {
$obj = $ADODB_NEWCONNECTION($db);

} else {

if (!isset($ADODB_LASTDB)) $ADODB_LASTDB = '';
if (empty($db)) $db = $ADODB_LASTDB;

if ($db != $ADODB_LASTDB) $db = ADOLoadCode($db);

if (!$db) {
if (isset($origdsn)) $db = $origdsn;
if ($errorfn) {
// raise an error
$ignore = false;
$errorfn('ADONewConnection', 'ADONewConnection', -998,
"could not load the database driver for '$db'",
$db,false,$ignore);
} else
ADOConnection::outp( "ADONewConnection: Unable to load database driver '$db'",false);

return false;
}

$cls = 'ADODB_'.$db;
if (!class_exists($cls)) {
adodb_backtrace();
return false;
}

$obj =& new $cls();
}

# constructor should not fail
if ($obj) {
if ($errorfn) $obj->raiseErrorFn = $errorfn;
if (isset($dsna)) {

foreach($opt as $k => $v) {
switch(strtolower($k)) {
case 'persist':
case 'persistent': $persist = $v; break;
case 'debug': $obj->debug = (integer) $v; break;
#ibase
case 'dialect': $obj->dialect = (integer) $v; break;
case 'charset': $obj->charset = $v; break;
case 'buffers': $obj->buffers = $v; break;
case 'fetchmode': $obj->SetFetchMode($v); break;
#ado
case 'charpage': $obj->charPage = $v; break;
#mysql, mysqli
case 'clientflags': $obj->clientFlags = $v; break;
#mysqli
case 'port': $obj->port = $v; break;
case 'socket': $obj->socket = $v; break;
}
}
if (empty($persist))
$ok = $obj->Connect($dsna['host'], $dsna['user'], $dsna['pass'], $dsna['path']);
else
$ok = $obj->PConnect($dsna['host'], $dsna['user'], $dsna['pass'], $dsna['path']);

if (!$ok) return false;
}
}
return $obj;
}



// $perf == true means called by NewPerfMonitor()
function _adodb_getdriver($provider,$drivername,$perf=false)
{
if ($provider !== 'native' && $provider != 'odbc' && $provider != 'ado')
$drivername = $provider;
else {
if (substr($drivername,0,5) == 'odbc_') $drivername = substr($drivername,5);
else if (substr($drivername,0,4) == 'ado_') $drivername = substr($drivername,4);
else
switch($drivername) {
case 'oracle': $drivername = 'oci8';break;
//case 'sybase': $drivername = 'mssql';break;
case 'access':
if ($perf) $drivername = '';
break;
case 'db2':
break;
default:
$drivername = 'generic';
break;
}
}

return $drivername;
}

function &NewPerfMonitor(&$conn)
{
$drivername = _adodb_getdriver($conn->dataProvider,$conn->databaseType,true);
if (!$drivername || $drivername == 'generic') return false;
include_once(ADODB_DIR.'/adodb-perf.inc.php');
@include_once(ADODB_DIR."/perf/perf-$drivername.inc.php");
$class = "Perf_$drivername";
if (!class_exists($class)) return false;
$perf =& new $class($conn);

return $perf;
}

function &NewDataDictionary(&$conn)
{
$drivername = _adodb_getdriver($conn->dataProvider,$conn->databaseType);

include_once(ADODB_DIR.'/adodb-lib.inc.php');
include_once(ADODB_DIR.'/adodb-datadict.inc.php');
$path = ADODB_DIR."/datadict/datadict-$drivername.inc.php";

if (!file_exists($path)) {
ADOConnection::outp("Database driver '$path' not available");
return false;
}
include_once($path);
$class = "ADODB2_$drivername";
$dict =& new $class();
$dict->dataProvider = $conn->dataProvider;
$dict->connection = &$conn;
$dict->upperName = strtoupper($drivername);
$dict->quote = $conn->nameQuote;
if (!empty($conn->_connectionID))
$dict->serverInfo = $conn->ServerInfo();

return $dict;
}



/*
Perform a print_r, with pre tags for better formatting.
*/
function adodb_pr($var)
{
if (isset($_SERVER['HTTP_USER_AGENT'])) {
echo " \n";print_r($var);echo "\n";
} else
print_r($var);
}

/*
Perform a stack-crawl and pretty print it.

@param printOrArr Pass in a boolean to indicate print, or an $exception->trace array (assumes that print is true then).
@param levels Number of levels to display
*/
function adodb_backtrace($printOrArr=true,$levels=9999)
{
global $ADODB_INCLUDED_LIB;
if (empty($ADODB_INCLUDED_LIB)) include_once(ADODB_DIR.'/adodb-lib.inc.php');
return _adodb_backtrace($printOrArr,$levels);
}

} // defined

//Added by InterAKT to include an addon to Adodb
@include_once(ADODB_DIR.'/Iakt/KT_adodb.inc.php');


?>
/code
Commenter la réponse de massbbc

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.