[Skip to main content](#vessel-content)

#   se connecter a une autre base dans plugin

##

- **[erickb](/forum/user/4069-erickb "View erickb's Profile")**
- [![erickb's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/4069-erickb "View erickb's Profile") Topic Author
- [ Offline](/forum/user/4069-erickb)

Less More

- Posts: 2704
- Thank you received: 74
-
-

14 years 2 months ago [\#66712](#66712) by [erickb](/forum/user/4069-erickb "View erickb's Profile")  *[se connecter a une autre base dans plugin](/forum/5-support-en-francais-french-support-/66712-se-connecter-a-une-autre-base-dans-plugin#66712 "Il faut que je cree un plugin qui va mettre a jour des données d'Hikashop dans une autre base de donnees sur le meme serveur  quel est la syntaxe de Joomla pour une autre connexion que celle de la config ?  Joomla utilise configuration.php  public $host = 'localhost'; public $user = 'erezrgerg'; public $password = 'gthkrh,'; public $db = 'sgerg'; public $dbprefix = 'grerge&#95;';  me faudrait un genre de $connexion = JFactory::getDBO(server, database, user,password,prefix)  merci")* was created by *[erickb](/forum/user/4069-erickb "View erickb's Profile")*

Il faut que je cree un plugin qui va mettre a jour des données d'Hikashop dans une autre base de donnees sur le meme serveur

quel est la syntaxe de Joomla pour une autre connexion que celle de la config ?

Joomla utilise configuration.php

public $host = 'localhost';
public $user = 'erezrgerg';
public $password = 'gthkrh,';
public $db = 'sgerg';
public $dbprefix = 'grerge_';

me faudrait un genre de $connexion = JFactory::getDBO(server, database, user,password,prefix)

merci

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzUtc3VwcG9ydC1lbi1mcmFuY2Fpcy1mcmVuY2gtc3VwcG9ydC0vNjY3MTItc2UtY29ubmVjdGVyLWEtdW5lLWF1dHJlLWJhc2UtZGFucy1wbHVnaW4/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Xavier](/forum/user/4105-xavier "View Xavier's Profile")**
- [![Xavier's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar4105.png)](/forum/user/4105-xavier "View Xavier's Profile")
- [ Offline](/forum/user/4105-xavier)

Less More

- Posts: 13201
- Thank you received: 2322
-
-
-
- [](http://www.kidiweb.fr)
-

14 years 1 month ago [\#66913](#66913) by [Xavier](/forum/user/4105-xavier "View Xavier's Profile")  Replied by *[Xavier](/forum/user/4105-xavier "View Xavier's Profile")* on topic *[Re: se connecter a une autre base dans plugin](/forum/5-support-en-francais-french-support-/66712-se-connecter-a-une-autre-base-dans-plugin#66913 "Il faut que je cree un plugin qui va mettre a jour des données d'Hikashop dans une autre base de donnees sur le meme serveur  quel est la syntaxe de Joomla pour une autre connexion que celle de la config ?  Joomla utilise configuration.php  public $host = 'localhost'; public $user = 'erezrgerg'; public $password = 'gthkrh,'; public $db = 'sgerg'; public $dbprefix = 'grerge&#95;';  me faudrait un genre de $connexion = JFactory::getDBO(server, database, user,password,prefix)  merci")*

Bonjour erickb,

Je pense que ceci relève plutôt du domaine de Joomla plutôt que HikaShop. Il serait préférable de poster sur le forum de Joomla.

A mon avis il faudrait se baser sur la fontcion getDBO de joomla: Code:

function &amp;getDBO() { static $instance; if (!is_object($instance)) { //get the debug configuration setting $conf =&amp; JFactory::getConfig(); $debug = $conf-&gt;getValue('config.debug'); $instance = JFactory::_createDBO(); $instance-&gt;debug($debug); } return $instance; }

Et au lieu de: "JFactory::getConfig();", faire un appel vers un autre fichier de configuration dans lequel il y aurait vos paramètres.
Mais je ne suis pas sûr de cette réponse.

The following user(s) said Thank You: [erickb](/forum/user/4069-erickb "View erickb's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzUtc3VwcG9ydC1lbi1mcmFuY2Fpcy1mcmVuY2gtc3VwcG9ydC0vNjY3MTItc2UtY29ubmVjdGVyLWEtdW5lLWF1dHJlLWJhc2UtZGFucy1wbHVnaW4/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[erickb](/forum/user/4069-erickb "View erickb's Profile")**
- [![erickb's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/4069-erickb "View erickb's Profile") Topic Author
- [ Offline](/forum/user/4069-erickb)

Less More

- Posts: 2704
- Thank you received: 74
-
-

14 years 1 month ago [\#66917](#66917) by [erickb](/forum/user/4069-erickb "View erickb's Profile")  Replied by *[erickb](/forum/user/4069-erickb "View erickb's Profile")* on topic *[Re: se connecter a une autre base dans plugin](/forum/5-support-en-francais-french-support-/66712-se-connecter-a-une-autre-base-dans-plugin#66917 "Il faut que je cree un plugin qui va mettre a jour des données d'Hikashop dans une autre base de donnees sur le meme serveur  quel est la syntaxe de Joomla pour une autre connexion que celle de la config ?  Joomla utilise configuration.php  public $host = 'localhost'; public $user = 'erezrgerg'; public $password = 'gthkrh,'; public $db = 'sgerg'; public $dbprefix = 'grerge&#95;';  me faudrait un genre de $connexion = JFactory::getDBO(server, database, user,password,prefix)  merci")*

c'est ce que j'avais trouve aussi
mais sous quelle forme et dans quel ordre cet array $options pour JDatabase::getInstance( $options) ; ?

ligne 249
[url][ api.joomla.org/11.4/\_\_filesource/fsource...tabase.php.html#a249](http://api.joomla.org/11.4/__filesource/fsource_Joomla-Platform_Database_librariesjoomladatabasedatabase.php.html#a249)[/url]

driver =&gt; 'mysql'
database =&gt; 'databasename' // je suppose
select =&gt; ??

à quel endroit et comment je passe user, password et prefix ?

merci pour l'aide

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzUtc3VwcG9ydC1lbi1mcmFuY2Fpcy1mcmVuY2gtc3VwcG9ydC0vNjY3MTItc2UtY29ubmVjdGVyLWEtdW5lLWF1dHJlLWJhc2UtZGFucy1wbHVnaW4/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Xavier](/forum/user/4105-xavier "View Xavier's Profile")**
- [![Xavier's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar4105.png)](/forum/user/4105-xavier "View Xavier's Profile")
- [ Offline](/forum/user/4105-xavier)

Less More

- Posts: 13201
- Thank you received: 2322
-
-
-
- [](http://www.kidiweb.fr)
-

14 years 1 month ago [\#66942](#66942) by [Xavier](/forum/user/4105-xavier "View Xavier's Profile")  Replied by *[Xavier](/forum/user/4105-xavier "View Xavier's Profile")* on topic *[Re: se connecter a une autre base dans plugin](/forum/5-support-en-francais-french-support-/66712-se-connecter-a-une-autre-base-dans-plugin#66942 "Il faut que je cree un plugin qui va mettre a jour des données d'Hikashop dans une autre base de donnees sur le meme serveur  quel est la syntaxe de Joomla pour une autre connexion que celle de la config ?  Joomla utilise configuration.php  public $host = 'localhost'; public $user = 'erezrgerg'; public $password = 'gthkrh,'; public $db = 'sgerg'; public $dbprefix = 'grerge&#95;';  me faudrait un genre de $connexion = JFactory::getDBO(server, database, user,password,prefix)  merci")*

Dans votre plugin, faites de cette sorte: Code:

$db = &amp; $this-&gt;getDBO();

Code:

function &amp;getDBO() { static $instance; if (!is_object($instance)) { //get the debug configuration setting $conf =&amp; JFactory::getConfig(); $debug = $conf-&gt;getValue('config.debug'); $instance = $this-&gt;_createDBO(); $instance-&gt;debug($debug); } return $instance; }

Code:

function &amp;_createDBO() { jimport('joomla.database.database'); jimport( 'joomla.database.table' ); $conf =&amp; JFactory::getConfig(); $host = //votre valeur $user = //votre valeur $password = //votre valeur $database = //votre valeur $prefix = //votre valeur $driver = $conf-&gt;getValue('config.dbtype'); $debug = $conf-&gt;getValue('config.debug'); $options = array ( 'driver' =&gt; $driver, 'host' =&gt; $host, 'user' =&gt; $user, 'password' =&gt; $password, 'database' =&gt; $database, 'prefix' =&gt; $prefix ); $db =&amp; JDatabase::getInstance( $options ); if ( JError::isError($db) ) { header('HTTP/1.1 500 Internal Server Error'); jexit('Database Error: ' . $db-&gt;toString() ); } if ($db-&gt;getErrorNum() &gt; 0) { JError::raiseError(500 , 'JDatabase::getInstance: Could not connect to database &lt;br /&gt;' . 'joomla.library:'.$db-&gt;getErrorNum().' - '.$db-&gt;getErrorMsg() ); } $db-&gt;debug( $debug ); return $db; }

The following user(s) said Thank You: [erickb](/forum/user/4069-erickb "View erickb's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzUtc3VwcG9ydC1lbi1mcmFuY2Fpcy1mcmVuY2gtc3VwcG9ydC0vNjY3MTItc2UtY29ubmVjdGVyLWEtdW5lLWF1dHJlLWJhc2UtZGFucy1wbHVnaW4/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[erickb](/forum/user/4069-erickb "View erickb's Profile")**
- [![erickb's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/4069-erickb "View erickb's Profile") Topic Author
- [ Offline](/forum/user/4069-erickb)

Less More

- Posts: 2704
- Thank you received: 74
-
-

14 years 1 month ago [\#66944](#66944) by [erickb](/forum/user/4069-erickb "View erickb's Profile")  Replied by *[erickb](/forum/user/4069-erickb "View erickb's Profile")* on topic *[Re: se connecter a une autre base dans plugin](/forum/5-support-en-francais-french-support-/66712-se-connecter-a-une-autre-base-dans-plugin#66944 "Il faut que je cree un plugin qui va mettre a jour des données d'Hikashop dans une autre base de donnees sur le meme serveur  quel est la syntaxe de Joomla pour une autre connexion que celle de la config ?  Joomla utilise configuration.php  public $host = 'localhost'; public $user = 'erezrgerg'; public $password = 'gthkrh,'; public $db = 'sgerg'; public $dbprefix = 'grerge&#95;';  me faudrait un genre de $connexion = JFactory::getDBO(server, database, user,password,prefix)  merci")*

Genial !

merci Xavier , c'est un truc a garder au chaud

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzUtc3VwcG9ydC1lbi1mcmFuY2Fpcy1mcmVuY2gtc3VwcG9ydC0vNjY3MTItc2UtY29ubmVjdGVyLWEtdW5lLWF1dHJlLWJhc2UtZGFucy1wbHVnaW4/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.051 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
