Beispiel #1
0
						$sqldrop="ALTER TABLE ".$val." DROP FOREIGN KEY ".$reg[1];
						$resqldrop = $db->query($sqldrop);
						if ($resqldrop)
						{
							print '<tr><td colspan="2">'.$sqldrop.";</td></tr>\n";
						}
						$createsql=preg_replace('/CONSTRAINT `'.$reg[1].'`/i','XXX',$createsql);
						$i++;
					}
					$db->free($resql);
				}
				else
				{
					if ($db->lasterrno() != 'DB_ERROR_NOSUCHTABLE')
					{
						print '<tr><td colspan="2"><font  class="error">'.$sql.' : '.$db->lasterror()."</font></td></tr>\n";
					}
				}
			}
		}
	}

	/*
	 *	Load sql files
	 */
	if ($ok)
	{
		$dir = "mysql/migration/";		// We use mysql migration scripts whatever is database driver

		$filelist=array();
		$i = 0;
 /**
  *   Load all objects with filters
  *
  *   @param		DoliDb	$db				Database handler
  *   @param		int		$socid			Filter by thirdparty
  * 	 @param		int		$fk_element		Id of element action is linked to
  *   @param		string	$elementtype	Type of element action is linked to
  *   @param		string	$filter			Other filter
  *   @param		string	$sortfield		Sort on this field
  *   @param		string	$sortorder		ASC or DESC
  *   @return	array or string			Error string if KO, array with actions if OK
  */
 static function getActions($db, $socid = 0, $fk_element = 0, $elementtype = '', $filter = '', $sortfield = '', $sortorder = '')
 {
     global $conf, $langs;
     $resarray = array();
     $sql = "SELECT a.id";
     $sql .= " FROM " . MAIN_DB_PREFIX . "actioncomm as a";
     $sql .= " WHERE a.entity IN (" . getEntity('actioncomm', 1) . ")";
     if (!empty($socid)) {
         $sql .= " AND a.fk_soc = " . $socid;
     }
     if (!empty($elementtype)) {
         if ($elementtype == 'project') {
             $sql .= ' AND a.fk_project = ' . $fk_element;
         } else {
             $sql .= " AND a.fk_element = " . $fk_element . " AND a.elementtype = '" . $elementtype . "'";
         }
     }
     if (!empty($filter)) {
         $sql .= $filter;
     }
     if ($sortorder && $sortfield) {
         $sql .= $db->order($sortfield, $sortorder);
     }
     dol_syslog(get_class() . "::getActions", LOG_DEBUG);
     $resql = $db->query($sql);
     if ($resql) {
         $num = $db->num_rows($resql);
         if ($num) {
             for ($i = 0; $i < $num; $i++) {
                 $obj = $db->fetch_object($resql);
                 $actioncommstatic = new ActionComm($db);
                 $actioncommstatic->fetch($obj->id);
                 $resarray[$i] = $actioncommstatic;
             }
         }
         $db->free($resql);
         return $resarray;
     } else {
         return $db->lasterror();
     }
 }
Beispiel #3
0
					$resql=$db->query($buffer);
					if ($resql)
					{
						$ok = 1;
						//$db->free($resql);     // Not required as request we launch here does not return memory needs.
					}
					else
					{
						if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
						{
							//print "<tr><td>Insertion ligne : $buffer</td><td>";
						}
						else
						{
							$ok = 0;
							print $langs->trans("ErrorSQL")." : ".$db->lasterrno()." - ".$db->lastqueryerror()." - ".$db->lasterror()."<br>";
						}
					}
				}
			}
		}

		print "<tr><td>".$langs->trans("ReferenceDataLoading")."</td>";
		if ($ok)
		{
			print "<td>".$langs->trans("OK")."</td></tr>";
		}
		else
		{
			print "<td>".$langs->trans("Error")."</td></tr>";
			$ok = 1 ;
Beispiel #4
0
					dolibarr_install_syslog('etape1: Note that default server was charset='.$check1.' collation='.$check2, LOG_DEBUG);

					// If values differs, we save conf file again
					//if ($check1 != $dolibarr_main_db_character_set) dolibarr_install_syslog('etape1: Value for character_set is not the one asked for database creation', LOG_WARNING);
					//if ($check2 != $dolibarr_main_db_collation)     dolibarr_install_syslog('etape1: Value for collation is not the one asked for database creation', LOG_WARNING);
				}
				else
				{
					// Affiche aide diagnostique
					print '<tr><td colspan="2"><br>';
					print $langs->trans("ErrorFailedToCreateDatabase",$dolibarr_main_db_name).'<br>';
					print $langs->trans("IfDatabaseExistsGoBackAndCheckCreate");
					print '<br>';
					print '</td></tr>';

					dolibarr_install_syslog('etape1: Failed to create database '.$dolibarr_main_db_name.' '.$db->lasterrno().' '.$db->lasterror(), LOG_ERR);
					$error++;
				}
				$db->close();
			}
			else {
				print '<tr><td>';
				print $langs->trans("DatabaseCreation")." (".$langs->trans("User")." ".$userroot.") : ";
				print $dolibarr_main_db_name;
				print '</td>';
				print '<td>'.$langs->trans("Error").'</td>';
				print '</tr>';

				// Affiche aide diagnostique
				print '<tr><td colspan="2"><br>';
				print $langs->trans("YouAskDatabaseCreationSoDolibarrNeedToConnect",$dolibarr_main_db_user,$dolibarr_main_db_host,$userroot);
Beispiel #5
0
				$error++;
			}
		}
	}
	else
	{
		print "<br>\nFailed to include_once(\"".$main_dir."/lib/databases/".$_POST["db_type"].".lib.php\")<br>\n";
		print '<div class="error">'.$langs->trans("ErrorWrongValueForParameter",$langs->transnoentities("WebPagesDirectory")).'</div>';
		print $langs->trans("ErrorGoBackAndCorrectParameters");
		$error++;
	}
}

else
{
	if (isset($db)) print $db->lasterror();
	if (isset($db) && ! $db->connected) print '<br>'.$langs->trans("BecauseConnectionFailedParametersMayBeWrong").'<br><br>';
	print $langs->trans("ErrorGoBackAndCorrectParameters");
	$error++;
}

/*
 * Si creation database demandee, il est possible de faire un choix
 */
$disabled="";
if (! $error && ! empty($_POST["db_create_database"]))
{
	$disabled="";
}else{
	$disabled="disabled";
}