Commit c0a30ee5 authored by Bozosoft's avatar Bozosoft

02/06/15 en développement v7.1 avec Smarty 3.124 et Adodb V5.19

parent 8df4510a
......@@ -7,14 +7,16 @@
* ---------------------------
*
* @author : JC Etiemble - http://jc.etiemble.free.fr
* @version : 2014
* @copyright 2007-2014 (c) JC Etiemble
* @version : 2015
* @copyright 2007-2015 (c) JC Etiemble
* @package GestAssoPhp+Pg
*/
Version 7.1.0 08/05/2015 - En développement
Version 7.1.0 01/06/2015 - En développement
-----------------------
- Correction sur export_tadhts.php (champ18) et export_tcotis.php (champ3 et 11)
- Mise à jour de Smarty 3.1.24 (23/05/2015) https://github.com/smarty-php/smarty
- Mise à jour de adodb en V5.19 23-Apr-2014 https://github.com/ADOdb/ADOdb
- Correction sur export_tadhts.php (champ18) et export_tcotis.php (champ3 et 11) 08/05/2015
Version 7.0.0 10/10/2014 Finale
-----------------------
......
ADODB Library for PHP5
======================
(c) 2000-2014 John Lim (jlim@natsoft.com)
Released under both BSD and GNU Lesser GPL library license.
This means you can use it in proprietary products.
Home page: http://adodb.sourceforge.net/
Introduction
============
PHP's database access functions are not standardized. This creates a
need for a database class library to hide the differences between the
different databases (encapsulate the differences) so we can easily
switch databases.
The library currently supports MySQL, Interbase, Sybase, PostgreSQL, Oracle,
Microsoft SQL server, Foxpro ODBC, Access ODBC, Informix, DB2,
Sybase SQL Anywhere, generic ODBC and Microsoft's ADO.
We hope more people will contribute drivers to support other databases.
Installation
============
Unpack all the files into a directory accessible by your web server.
To test, try modifying some of the tutorial examples.
Make sure you customize the connection settings correctly.
You can debug using:
``` php
<?php
include('adodb/adodb.inc.php');
$db = ADONewConnection($driver); # eg. 'mysql' or 'oci8'
$db->debug = true;
$db->Connect($server, $user, $password, $database);
$rs = $db->Execute('select * from some_small_table');
print "<pre>";
print_r($rs->GetRows());
print "</pre>";
```
Documentation and Examples
==========================
Refer to the `docs` directory for library documentation and examples.
- Main documentation: `docs-adodb.htm`.
Query, update and insert records using a portable API.
- Data dictionary docs: `docs-datadict.htm`.
Describes how to create database tables and indexes in a portable manner.
- Database performance monitoring docs: `docs-perf.htm`.
Allows you to perform health checks, tune and monitor your database.
- Database-backed session docs: `docs-session.htm`.
There is also a tutorial `tute.htm` that contrasts ADOdb code with
mysql code.
Files
=====
- `adodb.inc.php` is the library's main file. You only need to include this file.
- `adodb-*.inc.php` are the database specific driver code.
- `adodb-session.php` is the PHP4 session handling code.
- `test.php` contains a list of test commands to exercise the class library.
- `testdatabases.inc.php` contains the list of databases to apply the tests on.
- `Benchmark.php` is a simple benchmark to test the throughput of a SELECT
statement for databases described in testdatabases.inc.php. The benchmark
tables are created in test.php.
Feature Requests and Bug Reports
================================
Please report bugs, issues and feature requests on Github:
https://github.com/ADOdb/ADOdb/issues
You may also find legacy issues in
- the old [ADOdb forums](http://phplens.com/lens/lensforum/topics.php?id=4) on phplens.com
- the [SourceForge tickets section](http://sourceforge.net/p/adodb/_list/tickets)
However, please note that they are not actively monitored and should
only be used as reference.
......@@ -6,19 +6,19 @@ if (!defined('ADODB_DIR')) die();
global $ADODB_INCLUDED_CSV;
$ADODB_INCLUDED_CSV = 1;
/*
/*
V5.18 3 Sep 2012 (c) 2000-2012 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt.
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. See License.txt.
Set tabs to 4 for best viewing.
Latest version is available at http://adodb.sourceforge.net
Library for CSV serialization. This is used by the csv/proxy driver and is the
CacheExecute() serialization format.
Library for CSV serialization. This is used by the csv/proxy driver and is the
CacheExecute() serialization format.
==== NOTE ====
Format documented at http://php.weblogs.com/ADODB_CSV
==============
......@@ -34,61 +34,61 @@ $ADODB_INCLUDED_CSV = 1;
function _rs2serialize(&$rs,$conn=false,$sql='')
{
$max = ($rs) ? $rs->FieldCount() : 0;
if ($sql) $sql = urlencode($sql);
// metadata setup
if ($max <= 0 || $rs->dataProvider == 'empty') { // is insert/update/delete
if (is_object($conn)) {
$sql .= ','.$conn->Affected_Rows();
$sql .= ','.$conn->Insert_ID();
} else
$sql .= ',,';
$text = "====-1,0,$sql\n";
return $text;
}
$tt = ($rs->timeCreated) ? $rs->timeCreated : time();
## changed format from ====0 to ====1
$line = "====1,$tt,$sql\n";
if ($rs->databaseType == 'array') {
$rows = $rs->_array;
} else {
$rows = array();
while (!$rs->EOF) {
while (!$rs->EOF) {
$rows[] = $rs->fields;
$rs->MoveNext();
}
}
}
for($i=0; $i < $max; $i++) {
$o = $rs->FetchField($i);
$flds[] = $o;
}
$savefetch = isset($rs->adodbFetchMode) ? $rs->adodbFetchMode : $rs->fetchMode;
$class = $rs->connection->arrayClass;
$rs2 = new $class();
$rs2->timeCreated = $rs->timeCreated; # memcache fix
$rs2->sql = $rs->sql;
$rs2->oldProvider = $rs->dataProvider;
$rs2->oldProvider = $rs->dataProvider;
$rs2->InitArrayFields($rows,$flds);
$rs2->fetchMode = $savefetch;
return $line.serialize($rs2);
}
/**
* Open CSV file and convert it into Data.
* Open CSV file and convert it into Data.
*
* @param url file/ftp/http url
* @param err returns the error message
* @param timeout dispose if recordset has been alive for $timeout secs
*
* @return recordset, or false if error occured. If no
* error occurred in sql INSERT/UPDATE/DELETE,
* error occurred in sql INSERT/UPDATE/DELETE,
* empty recordset is returned
*/
function csv2rs($url,&$err,$timeout=0, $rsclass='ADORecordSet_array')
......@@ -103,7 +103,7 @@ $ADODB_INCLUDED_CSV = 1;
@flock($fp, LOCK_SH);
$arr = array();
$ttl = 0;
if ($meta = fgetcsv($fp, 32000, ",")) {
// check if error message
if (strncmp($meta[0],'****',4) === 0) {
......@@ -113,10 +113,10 @@ $ADODB_INCLUDED_CSV = 1;
}
// check for meta data
// $meta[0] is -1 means return an empty recordset
// $meta[1] contains a time
// $meta[1] contains a time
if (strncmp($meta[0], '====',4) === 0) {
if ($meta[0] == "====-1") {
if (sizeof($meta) < 5) {
$err = "Corrupt first line for format -1";
......@@ -124,12 +124,12 @@ $ADODB_INCLUDED_CSV = 1;
return $false;
}
fclose($fp);
if ($timeout > 0) {
$err = " Illegal Timeout $timeout ";
return $false;
}
$rs = new $rsclass($val=true);
$rs->fields = array();
$rs->timeCreated = $meta[1];
......@@ -137,9 +137,9 @@ $ADODB_INCLUDED_CSV = 1;
$rs->_numOfFields = 0;
$rs->sql = urldecode($meta[2]);
$rs->affectedrows = (integer)$meta[3];
$rs->insertid = $meta[4];
$rs->insertid = $meta[4];
return $rs;
}
}
# Under high volume loads, we want only 1 thread/process to _write_file
# so that we don't have 50 processes queueing to write the same data.
# We use probabilistic timeout, ahead of time.
......@@ -149,7 +149,7 @@ $ADODB_INCLUDED_CSV = 1;
# -1 sec after timeout give processes 1/4 chance of timing out
# +0 sec after timeout, give processes 100% chance of timing out
if (sizeof($meta) > 1) {
if($timeout >0){
if($timeout >0){
$tdiff = (integer)( $meta[1]+$timeout - time());
if ($tdiff <= 2) {
switch($tdiff) {
......@@ -161,7 +161,7 @@ $ADODB_INCLUDED_CSV = 1;
return $false;
}
break;
case 2:
case 2:
if ((rand() & 15) == 0) {
fclose($fp);
$err = "Timeout 2";
......@@ -175,12 +175,12 @@ $ADODB_INCLUDED_CSV = 1;
return $false;
}
break;
default:
default:
fclose($fp);
$err = "Timeout 0";
return $false;
} // switch
} // if check flush cache
}// (timeout>0)
$ttl = $meta[1];
......@@ -190,7 +190,7 @@ $ADODB_INCLUDED_CSV = 1;
if ($meta[0] === '====1') {
// slurp in the data
$MAXSIZE = 128000;
$text = fread($fp,$MAXSIZE);
if (strlen($text)) {
while ($txt = fread($fp,$MAXSIZE)) {
......@@ -206,7 +206,7 @@ $ADODB_INCLUDED_CSV = 1;
}
return $rs;
}
$meta = false;
$meta = fgetcsv($fp, 32000, ",");
if (!$meta) {
......@@ -236,15 +236,15 @@ $ADODB_INCLUDED_CSV = 1;
$err = "Recordset had unexpected EOF 2";
return $false;
}
// slurp in the data
$MAXSIZE = 128000;
$text = '';
while ($txt = fread($fp,$MAXSIZE)) {
$text .= $txt;
}
fclose($fp);
@$arr = unserialize($text);
//var_dump($arr);
......@@ -258,18 +258,18 @@ $ADODB_INCLUDED_CSV = 1;
$rs->InitArrayFields($arr,$flds);
return $rs;
}
/**
* Save a file $filename and its $contents (normally for caching) with file locking
* Returns true if ok, false if fopen/fwrite error, 0 if rename error (eg. file is locked)
*/
function adodb_write_file($filename, $contents,$debug=false)
{
{
# 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
# 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
# modified the file exclusively.
# What a stupid need - having to simulate locking.
# Risks:
......@@ -279,14 +279,14 @@ $ADODB_INCLUDED_CSV = 1;
# 4. another process creates $filename between unlink() and rename() -- ok, rename() fails and cache updated
if (strncmp(PHP_OS,'WIN',3) === 0) {
// skip the decimal place
$mtime = substr(str_replace(' ','_',microtime()),2);
$mtime = substr(str_replace(' ','_',microtime()),2);
// getmypid() actually returns 0 on Win98 - never mind!
$tmpname = $filename.uniqid($mtime).getmypid();
if (!($fd = @fopen($tmpname,'w'))) return false;
if (fwrite($fd,$contents)) $ok = true;
else $ok = false;
fclose($fd);
if ($ok) {
@chmod($tmpname,0644);
// the tricky moment
......@@ -312,7 +312,6 @@ $ADODB_INCLUDED_CSV = 1;
if ($debug)ADOConnection::outp( " Failed acquiring lock for $filename<br>\n");
$ok = false;
}
return $ok;
}
?>
\ No newline at end of file
This diff is collapsed.
<?php
/**
* @version V5.18 3 Sep 2012 (c) 2000-2012 John Lim (jlim#natsoft.com). All rights reserved.
* Released under both BSD license and Lesser GPL library license.
* Whenever there is any discrepancy between the two licenses,
* the BSD license will take precedence.
/**
* @version V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
* Released under both BSD license and Lesser GPL library license.
* Whenever there is any discrepancy between the two licenses,
* the BSD license will take precedence.
*
* Set tabs to 4 for best viewing.
*
*
* The following code is adapted from the PEAR DB error handling code.
* Portions (c)1997-2002 The PHP Group.
*/
......@@ -62,27 +62,27 @@ function adodb_error($provider,$dbType,$errno)
{
//var_dump($errno);
if (is_numeric($errno) && $errno == 0) return 0;
switch($provider) {
switch($provider) {
case 'mysql': $map = adodb_error_mysql(); break;
case 'oracle':
case 'oci8': $map = adodb_error_oci8(); break;
case 'ibase': $map = adodb_error_ibase(); break;
case 'odbc': $map = adodb_error_odbc(); break;
case 'mssql':
case 'sybase': $map = adodb_error_mssql(); break;
case 'informix': $map = adodb_error_ifx(); break;
case 'postgres': return adodb_error_pg($errno); break;
case 'sqlite': return $map = adodb_error_sqlite(); break;
default:
return DB_ERROR;
}
}
//print_r($map);
//var_dump($errno);
if (isset($map[$errno])) return $map[$errno];
......@@ -95,29 +95,29 @@ function adodb_error_pg($errormsg)
{
if (is_numeric($errormsg)) return (integer) $errormsg;
// Postgres has no lock-wait timeout. The best we could do would be to set a statement timeout.
static $error_regexps = array(
'/(Table does not exist\.|Relation [\"\'].*[\"\'] does not exist|sequence does not exist|class ".+" not found)$/i' => DB_ERROR_NOSUCHTABLE,
'/Relation [\"\'].*[\"\'] already exists|Cannot insert a duplicate key into (a )?unique index.*|duplicate key.*violates unique constraint/i' => DB_ERROR_ALREADY_EXISTS,
'/database ".+" does not exist$/i' => DB_ERROR_NOSUCHDB,
'/(divide|division) by zero$/i' => DB_ERROR_DIVZERO,
'/pg_atoi: error in .*: can\'t parse /i' => DB_ERROR_INVALID_NUMBER,
'/ttribute [\"\'].*[\"\'] not found|Relation [\"\'].*[\"\'] does not have attribute [\"\'].*[\"\']/i' => DB_ERROR_NOSUCHFIELD,
'/(parser: parse|syntax) error at or near \"/i' => DB_ERROR_SYNTAX,
'/referential integrity violation/i' => DB_ERROR_CONSTRAINT,
'/deadlock detected$/i' => DB_ERROR_DEADLOCK,
'/canceling statement due to statement timeout$/i' => DB_ERROR_STATEMENT_TIMEOUT,
'/could not serialize access due to/i' => DB_ERROR_SERIALIZATION_FAILURE
);
static $error_regexps = array(
'(Table does not exist\.|Relation [\"\'].*[\"\'] does not exist|sequence does not exist|class ".+" not found)$' => DB_ERROR_NOSUCHTABLE,
'Relation [\"\'].*[\"\'] already exists|Cannot insert a duplicate key into (a )?unique index.*|duplicate key.*violates unique constraint' => DB_ERROR_ALREADY_EXISTS,
'database ".+" does not exist$' => DB_ERROR_NOSUCHDB,
'(divide|division) by zero$' => DB_ERROR_DIVZERO,
'pg_atoi: error in .*: can\'t parse ' => DB_ERROR_INVALID_NUMBER,
'ttribute [\"\'].*[\"\'] not found|Relation [\"\'].*[\"\'] does not have attribute [\"\'].*[\"\']' => DB_ERROR_NOSUCHFIELD,
'(parser: parse|syntax) error at or near \"' => DB_ERROR_SYNTAX,
'referential integrity violation' => DB_ERROR_CONSTRAINT,
'deadlock detected$' => DB_ERROR_DEADLOCK,
'canceling statement due to statement timeout$' => DB_ERROR_STATEMENT_TIMEOUT,
'could not serialize access due to' => DB_ERROR_SERIALIZATION_FAILURE
);
reset($error_regexps);
while (list($regexp,$code) = each($error_regexps)) {
if (preg_match($regexp, $errormsg)) {
return $code;
}
}
// Fall back to DB_ERROR if there was no mapping.
return DB_ERROR;
while (list($regexp,$code) = each($error_regexps)) {
if (preg_match("/$regexp/mi", $errormsg)) {
return $code;
}
}
// Fall back to DB_ERROR if there was no mapping.
return DB_ERROR;
}
function adodb_error_odbc()
{
static $MAP = array(
......@@ -175,7 +175,7 @@ static $MAP = array(
-923 => DB_ERROR_CONNECT_FAILED,
-924 => DB_ERROR_CONNECT_FAILED
);
return $MAP;
}
......@@ -193,7 +193,7 @@ static $MAP = array(
'-1210' => DB_ERROR_INVALID_DATE,
'-1212' => DB_ERROR_INVALID_DATE
);
return $MAP;
}
......@@ -212,7 +212,7 @@ static $MAP = array(
2291 => DB_ERROR_CONSTRAINT,
2449 => DB_ERROR_CONSTRAINT
);
return $MAP;
}
......@@ -222,7 +222,7 @@ static $MAP = array(
208 => DB_ERROR_NOSUCHTABLE,
2601 => DB_ERROR_ALREADY_EXISTS
);
return $MAP;
}
......@@ -231,7 +231,7 @@ function adodb_error_sqlite()
static $MAP = array(
1 => DB_ERROR_SYNTAX
);
return $MAP;
}
......@@ -258,7 +258,6 @@ static $MAP = array(
2002 => DB_ERROR_CONNECT_FAILED,
2005 => DB_ERROR_CONNECT_FAILED
);
return $MAP;
}
?>
\ No newline at end of file
<?php
/**
* @version V5.18 3 Sep 2012 (c) 2000-2012 John Lim (jlim#natsoft.com). All rights reserved.
* @version V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
* Released under both BSD license and Lesser GPL library license.
* Whenever there is any discrepancy between the two licenses,
* the BSD license will take precedence.
......@@ -13,7 +13,7 @@
// added Claudio Bustos clbustos#entelchile.net
if (!defined('ADODB_ERROR_HANDLER_TYPE')) define('ADODB_ERROR_HANDLER_TYPE',E_USER_ERROR);
if (!defined('ADODB_ERROR_HANDLER_TYPE')) define('ADODB_ERROR_HANDLER_TYPE',E_USER_ERROR);
if (!defined('ADODB_ERROR_HANDLER')) define('ADODB_ERROR_HANDLER','ADODB_Error_Handler');
......@@ -74,6 +74,5 @@ function ADODB_Error_Handler($dbms, $fn, $errno, $errmsg, $p1, $p2, &$thisConnec
//print "<p>$s</p>";
trigger_error($s,ADODB_ERROR_HANDLER_TYPE);
trigger_error($s,ADODB_ERROR_HANDLER_TYPE);
}
?>
<?php
/**
* @version V5.18 3 Sep 2012 (c) 2000-2012 John Lim (jlim#natsoft.com). All rights reserved.
* @version V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
* Released under both BSD license and Lesser GPL library license.
* Whenever there is any discrepancy between the two licenses,
* the BSD license will take precedence.
......@@ -14,7 +14,7 @@
*/
if (!defined('ADODB_ERROR_HANDLER_TYPE')) define('ADODB_ERROR_HANDLER_TYPE',E_USER_ERROR);
if (!defined('ADODB_ERROR_HANDLER_TYPE')) define('ADODB_ERROR_HANDLER_TYPE',E_USER_ERROR);
define('ADODB_ERROR_HANDLER','adodb_throw');
class ADODB_Exception extends Exception {
......@@ -24,7 +24,7 @@ var $sql = '';
var $params = '';
var $host = '';
var $database = '';
function __construct($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection)
{
switch($fn) {
......@@ -33,7 +33,7 @@ var $database = '';
$this->params = $p2;
$s = "$dbms error: [$errno: $errmsg] in $fn(\"$p1\")\n";
break;
case 'PCONNECT':
case 'CONNECT':
$user = $thisConnection->user;
......@@ -43,7 +43,7 @@ var $database = '';
$s = "$dbms error: [$errno: $errmsg] in $fn($p1, $p2)\n";
break;
}
$this->dbms = $dbms;
if ($thisConnection) {
$this->host = $thisConnection->host;
......@@ -51,7 +51,7 @@ var $database = '';
}
$this->fn = $fn;
$this->msg = $errmsg;
if (!is_numeric($errno)) $errno = -1;
parent::__construct($s,$errno);
}
......@@ -71,12 +71,9 @@ var $database = '';
function adodb_throw($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection)
{
global $ADODB_EXCEPTION;
if (error_reporting() == 0) return; // obey @ protocol
if (is_string($ADODB_EXCEPTION)) $errfn = $ADODB_EXCEPTION;
else $errfn = 'ADODB_EXCEPTION';
throw new $errfn($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection);
}
?>
\ No newline at end of file
<?php
/*
V5.18 3 Sep 2012 (c) 2000-2012 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
V5.19 23-Apr-2014 (c) 2000-2014 John Lim (jlim#natsoft.com). All rights reserved.
Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence.
Set tabs to 4.
Declares the ADODB Base Class for PHP5 "ADODB_BASE_RS", and supports iteration with
Declares the ADODB Base Class for PHP5 "ADODB_BASE_RS", and supports iteration with
the ADODB_Iterator class.
$rs = $db->Execute("select * from adoxyz");
foreach($rs as $k => $v) {
echo $k; print_r($v); echo "<br>";
}
Iterator code based on http://cvs.php.net/cvs.php/php-src/ext/spl/examples/cachingiterator.inc?login=2
Moved to adodb.inc.php to improve performance.
*/
Iterator code based on http://cvs.php.net/cvs.php/php-src/ext/spl/examples/cachingiterator.inc?login=2
?>
\ No newline at end of file
Moved to adodb.inc.php to improve performance.
*/
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Change Log http://phplens.com/adodb/change.log.html
----------