Précédent   Forum des professionnels en informatique > PHP > Outils > Zend > Zend Framework > Zend_Db
Zend_Db Forum d'entraide pour le composant Zend_Db du Zend Framework (création de requêtes, abstraction, ORM etc.). Avant de poster -> FAQ Zend_Db.
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 15/02/2008, 18h57   #1
Membre expérimenté
 
Avatar de hansaplast
 
Inscription : septembre 2005
Messages : 925
Détails du profil
Informations personnelles :
Âge : 30
Localisation : France, Isère (Rhône Alpes)

Informations forums :
Inscription : septembre 2005
Messages : 925
Points : 562
Points : 562
Par défaut [Zend_Db] Comment aborder la réplication ?

Bonjour,

je me demande comment, en respectant une logique ORM :
ex :

1- find
2- modification des données
3- save


utiliser plusieurs serveur en rplication, mais forcer l'ecriture sur un seul.

il y aurait bien la possibilitée d'utiliser la methode setTable :
http://framework.zend.com/manual/en/...table.row.html
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php
 
$bugs = new Bugs();
$bugs->setDefaultAdapter($dbSlave);
$rowSet = $bugs->find('foo');
$row = array_pop($rowSet);
 
$row->bug_status = 'FIXED';
 
$bugsMaster  = new Bugs();
$bugsMaster ->setDefaultAdapter($dbMaster);
$row->setTable($bugsMaster);
 
$row->save();

mais, je trouve cette methode assez lourde.

avez vous d'autres idées?
hansaplast est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 16/02/2008, 00h56   #2
Membre expérimenté
 
Avatar de hansaplast
 
Inscription : septembre 2005
Messages : 925
Détails du profil
Informations personnelles :
Âge : 30
Localisation : France, Isère (Rhône Alpes)

Informations forums :
Inscription : septembre 2005
Messages : 925
Points : 562
Points : 562
une autre solution consisterait a etendre les methodes _insert, _update, ...

cf :
http://framework.zend.com/manual/en/...table.row.html
Citation:
Example 10.121. Example of custom logic in a Row class

The custom logic may not apply in all cases of operations on the respective Table. You can provide custom logic on demand by implementing it in a Row class and creating an instance of the Table class with that custom Row class specified. Otherwise, the Table uses the default Row class.

You need data operations on this table to record the operation to a Zend_Log object, but only if the application configuration has enabled this behavior.
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php
class MyLoggingRow extends Zend_Db_Table_Row_Abstract
{
    protected function _insert()
    {
        $log = Zend_Registry::get('database_log');
        $log->info(Zend_Debug::dump($this->_data, "INSERT: $this->_tableClass", false));
    }
}
// $loggingEnabled is an example property that depends
// on your application configuration
if ($loggingEnabled) {
    $bugs = new Bugs(array('rowClass' => 'MyLoggingRow'));
} else {
    $bugs = new Bugs();
}
en reprenant leur exemple, pour du insert / update / delete => forcer l'adapteateur sur le master, pour le select => forcer sur les slaves.

reste le pb des proc. sto sur lequel je ne me suis pas encore penché.
__________________
Vous un sur Grenoble? on est fait pour tout du moins si vous mon CV
hansaplast est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 19h31.


 
 
 
 
Partenaires

Hébergement Web