Welcome Guest, Not a member yet? Register   Sign In
DMZ 1.7.1 (DataMapper OverZealous Edition)

[eluser]tomdelonge[/eluser]
Is there something already in place for dmz that allows for write queries to go to a master database and read queries to come from a slave database? Would dmz be the correct layer to have this functionality?

[eluser]OverZealous[/eluser]
@tomdelonge
I think, without question, DMZ is the wrong place for this functionality. This should be handled transparently using a replication or pooling library.

For example, with PostgreSQL, I've had great luck with PGPOOL-II. This allows connection pooling, master/slave style replication, and more. The best part is that PHP makes normal connections to the DB (sans pconnect), and the only change in the code is changing the port number. The performance increase, even with a single database server, was noticeable (due mostly to the connection pooling).

Either way, DMZ does not support that, and I wouldn't expect it to be possible on a code-level with this style library, or even with CodeIgniter in general.

[eluser]tomdelonge[/eluser]
@overzealous

I'm having troubles understanding how it could be handled by a library. My understanding is that with mysql, if you've got replication working, then there's a master database and several slave databases.

All write queries should go to the master and all read queries should come from the slaves.

These databases are on different servers. In codeigniter, in the config file called database.php, when you set up a connection you choose a hostname. Is that just supposed to be the master database? And if so, does mysql just reroute read queries and write queries accordingly? I guess I'm hoping that's the case (it'd be simplest from a development perspective), but I wouldn't have imagined that.

Am I understanding this correctly?

[eluser]OverZealous[/eluser]
@tomdelonge
No, not really. PGPOOL-II, for example, is an application library (NOT a CodeIgniter library) that sits between PHP and PostgreSQL. There's similar libraries (or configurations) for MySQL, and pretty much all the other DBs out there. Personally, I avoid MySQL when possible, so I can't help you much with that specific set up. Once you set these up, they provide a connection to PHP that looks like a single server.

As far as PHP is concerned, it's still connecting to one database server. It doesn't care about where it reads or writes. The pooling / replication library automatically decides if a query should be sent to one server or another, based on load, read vs write, and many other factors that are beyond my skill level. With replication, writes are usually made across the bored, atomically, but reads are usually distributed.

[eluser]Daniel H[/eluser]
I want to be able to use the neat
Code:
include_related_count
, but for a different sort of relationship.

Each event has a created_by, which is a user. I can't simply do
Code:
$events->include_related_count('user')
because this relationship doesn't exist, and I tried
Code:
$events->include_related_count('created_by')
but this didn't seem to work.

Any idea how I can do this?

[eluser]ronnie_nsu[/eluser]
I have these two dmz models...
Code:
class cart_m_cart extends a_base_model_datamapper {

    public function __construct($id=null) {
        $this->table = 'carts';
        $this->has_many = array(
        );
        $this->has_one = array(
        );

        $this->has_many['item_m_cart'] = array(
            'class' => 'item_m_cart',
            'join_other_as' => 'item',
            'join_self_as' => 'cart'
        );
        parent::__construct($id);
    }
}
class item_m_cart extends a_base_model_datamapper {
Code:
public function __construct($id=null) {
        $this->table = 'cart_items';
        $this->has_many = array(
        );
        $this->has_one = array(
        );

        $this->has_one['cart_m_cart'] = array(
            'class' => 'cart_m_cart',
            'join_other_as' => 'cart',
            'join_self_as' => 'item'
        );
        parent::__construct($id);
    }
}

i am trying to add an item in the cart..but it doesnt seem to work..help please
Code:
$c = new cart_m_cart();
        $c->user_id = 2;
        $c->site_id = 2;
        $c->get();

        $ci = new item_m_cart();      
        $ci->product_id = 1;
        $ci->qty = 5;
      
        
        $c->save($ci);

[eluser]OverZealous[/eluser]
@ronnie_nsu

Did you even read the manual?? Your code looks nothing like the examples. You didn't even take advantage of the template model..

Please look at the manual and check out the included example application.

[eluser]eXpi[/eluser]
Hi, and thanks for this great plugin.

I'm having a little problem with datamapper. I'm currently programming an ordering system. Products can have many categories and categories can have many products. I figured out that finding products that are related to a category is very easy:

Code:
$cat = new Category($id);
$cat->product->get();

But I can't figure out how to get all the other products that are NOT related to the category?

Thanks for help.

[eluser]OverZealous[/eluser]
@eXpi

There's no built-in functionality for this. Solving this depends on how the items are related. If it's a one-to-many relationsip and you are using ITFKs, then you can simply query against the relationship column. Otherwise, you'll need to hand-build the query.

[eluser]pilotdev[/eluser]
I absolutely love this package (great work!) but I'm having trouble using it on CI2.0 + Modular Extensions (and HMVC framework). Wondering if anyone else is working in the same environment.

These are the errors I'm getting, they seem to be specific to ME but I thought it wouldn't hurt getting some feedback/ideas to lead me in a direction:

EDIT: Silly me, it seems to work perfectly. Not for future users doing the same thing: be very attentive to how you're configuring ME and some minor tweaking may be necessary in DataMapper itself.




Theme © iAndrew 2016 - Forum software by © MyBB