
Merci à toi, le sujet est donc réglé.
Bonjour et bienvenue,
Si c'est votre première visite, nous vous invitons à consulter la Foire Aux Questions. Avant de pouvoir poster une question, vous devez vous enregistrer sur le site. Pour voir les messages, sélectionnez le forum que vous voulez visiter depuis la liste ci-dessous.
Rapide mode d'emploi pour créer une note :
L'Association Francophone des Utilisateurs de Joomla!™ est une association à but non lucratif, loi 1901. Elle a pour vocation de faire connaître le CMS Joomla!™ à travers son portail joomla.fr, le Joomladay, les rencontres JUGs et des évènements tels les salons sur logiciels libres.
Cordialement, et bonne continuation avec Joomla! : l'équipe du forum.
/**
* Quotes and optionally escapes a string to database requirements for use in database queries.
*
* @param mixed $text A string or an array of strings to quote.
* @param boolean $escape True (default) to escape the string, false to leave it unchanged.
*
* @return string The quoted input string.
*
* @note Accepting an array of strings was added in 12.3.
* [USER="57695"]since[/USER] 11.1
*/
public function quote($text, $escape = true)
{
if (is_array($text))
{
foreach ($text as $k => $v)
{
$text[$k] = $this->quote($v, $escape);
}
return $text;
}
else
{
return '\'' . ($escape ? $this->escape($text) : $text) . '\'';
}
}
/**
* Method to escape a string for usage in an SQL statement.
*
* @param string $text The string to be escaped.
* @param boolean $extra Optional parameter to provide extra escaping.
*
* @return string The escaped string.
*
* [USER="57695"]since[/USER] 12.1
*/
public function escape($text, $extra = false)
{
$this->connect();
$result = mysqli_real_escape_string($this->getConnection(), $text);
if ($extra)
{
$result = addcslashes($result, '%_');
}
return $result;
}
$connexion = mysqli_connect("localhost", "user", "pass", "nom");
$db = JFactory::getDBO();
$chaine = mysqli_real_escape_string($db, $chaine);
/**
* Method to return a JDatabaseDriver instance based on the given options. There are three global options and then
* the rest are specific to the database driver. The 'driver' option defines which JDatabaseDriver class is
* used for the connection -- the default is 'mysqli'. The 'database' option determines which database is to
* be used for the connection. The 'select' option determines whether the connector should automatically select
* the chosen database.
*
* Instances are unique to the given options and new objects are only created when a unique options array is
* passed into the method. This ensures that we don't end up with unnecessary database connection resources.
*
* @param array $options Parameters to be passed to the database driver.
*
* @return JDatabaseDriver A database object.
*
* [USER="57695"]since[/USER] 11.1
* @throws RuntimeException
*/
public static function getInstance($options = array())
{
// Sanitize the database connector options.
$options['driver'] = (isset($options['driver'])) ? preg_replace('/[^A-Z0-9_\.-]/i', '', $options['driver']) : 'mysqli';
$options['database'] = (isset($options['database'])) ? $options['database'] : null;
$options['select'] = (isset($options['select'])) ? $options['select'] : true;
$db = JFactory::getDBO();
$options = array("database" => "ma_table");
$db->getInstance($options);
$connexion = mysqli_connect("localhost", "user", "pass", "nom");
$db = JFactory::getDBO();
Laisser un commentaire: