Injection database
This commit is contained in:
parent
6852da1c60
commit
ad1b8c0407
@ -1,7 +1,6 @@
|
||||
<?
|
||||
|
||||
class MOrias {
|
||||
|
||||
<?php
|
||||
class MOrias
|
||||
{
|
||||
private $referer ='';
|
||||
private $body = '';
|
||||
private $header = '';
|
||||
@ -15,12 +14,19 @@ class MOrias {
|
||||
public $annee=0;
|
||||
public $erreur='';
|
||||
|
||||
function __construct($accesDist=true) {// $adresse, $cp, $ville, $pays='France') {
|
||||
$this->accesDist=$accesDist;
|
||||
$this->iDb=new WDb('sdv1');
|
||||
function __construct($accesDist = true, $db = null)
|
||||
{
|
||||
$this->accesDist = $accesDist;
|
||||
|
||||
if ( $db === null ) {
|
||||
$this->iDb = new WDB();
|
||||
} else {
|
||||
$this->iDb = $db;
|
||||
}
|
||||
}
|
||||
|
||||
public function getMaxOrias($annee=0) {
|
||||
public function getMaxOrias($annee=0)
|
||||
{
|
||||
if ($annee*1>0 && $annee*1<100) {
|
||||
$this->annee='20'.$annee;
|
||||
$annee++;
|
||||
@ -34,12 +40,13 @@ class MOrias {
|
||||
$this->annee=date('Y')*1;
|
||||
}
|
||||
|
||||
$ret=$this->iDb->select('orias','MAX(numOrias) AS numOrias', $strWhere, false, MYSQL_ASSOC);
|
||||
$ret=$this->iDb->select('sdv1.orias','MAX(numOrias) AS numOrias', $strWhere, false, MYSQL_ASSOC);
|
||||
//die($strWhere);
|
||||
return sprintf('%08d',$ret[0]['numOrias']);
|
||||
}
|
||||
|
||||
public function getInfosOrias($siren, $numOrias=0) {
|
||||
public function getInfosOrias($siren, $numOrias=0)
|
||||
{
|
||||
//die('numOrias 1:"'.$numOrias.'"');
|
||||
if ($siren*1>1000)
|
||||
$strWhere="siren=$siren";
|
||||
@ -55,11 +62,11 @@ class MOrias {
|
||||
echo "==== SELECT siren, id, nom, cp, ville, adresse, numOrias FROM orias WHERE $strWhere;".EOL;
|
||||
echo "=================================================================================================".EOL;
|
||||
*/
|
||||
$ret=$this->iDb->select('orias','siren, id, nom, cp, ville, adresse, numOrias, numOriasAttribue', $strWhere, false, MYSQL_ASSOC);
|
||||
$ret=$this->iDb->select('sdv1.orias','siren, id, nom, cp, ville, adresse, numOrias, numOriasAttribue', $strWhere, false, MYSQL_ASSOC);
|
||||
if (!$this->force && count($ret)>0) {
|
||||
$this->enCache=true;
|
||||
$tabRet=$ret[0];//array();
|
||||
$ret=$this->iDb->select('orias','categorie, cat, dateInscription, typeStatut, rcsVille, rcsCode, rcsSiren, contact, encaissement, nature, paysPresta, paysEtab',$strWhere, false, MYSQL_ASSOC);
|
||||
$ret=$this->iDb->select('sdv1.orias','categorie, cat, dateInscription, typeStatut, rcsVille, rcsCode, rcsSiren, contact, encaissement, nature, paysPresta, paysEtab',$strWhere, false, MYSQL_ASSOC);
|
||||
foreach ($ret as $i=>$tabTmp)
|
||||
$tabRet['categories'][]=$tabTmp;
|
||||
//die('numOrias 3:"'.$numOrias.'"');
|
||||
@ -116,7 +123,7 @@ class MOrias {
|
||||
$this->erreur='Numéro Orias inexistant';
|
||||
// On enregistre ce numéro comme non attribué si < au dernier numéro attribué
|
||||
if ($numOrias<$this->getMaxOrias())
|
||||
$this->iDb->insert('orias', $tabInsert);
|
||||
$this->iDb->insert('sdv1.orias', $tabInsert);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -187,7 +194,7 @@ class MOrias {
|
||||
if (count($tabTmp)==1) {
|
||||
$tabInsert=array_merge($tabRet, array('dateInsert'=>date('YmdHis')));
|
||||
//print_r($tabInsert);
|
||||
$this->iDb->insert('orias', $tabInsert);
|
||||
$this->iDb->insert('sdv1.orias', $tabInsert);
|
||||
}
|
||||
$tabRet['categories']=array();
|
||||
continue;
|
||||
@ -272,7 +279,7 @@ class MOrias {
|
||||
unset($tabInsert['categories']);
|
||||
$tabInsert=array_merge($tabInsert, $tabCat, array('dateInsert'=>date('YmdHis')));
|
||||
//print_r($tabInsert);
|
||||
$this->iDb->insert('orias', $tabInsert);
|
||||
$this->iDb->insert('sdv1.orias', $tabInsert);
|
||||
//echo $tmpCat[$i];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user