EllisLab text mark
Advanced Search
45 of 62
45
   
DMZ 1.7.1 (DataMapper OverZealous Edition)
Posted: 02 October 2010 07:53 PM   [ # 661 ]   [ Rating: 0 ]
Avatar
Joined: 2009-11-16
35 posts

@WanWizard Did you use the nested set model like in http://dev.mysql.com/tech-resources/articles/hierarchical-data.html ?

Using this, with 1 query you can retrieve the full tree…

 
Posted: 04 October 2010 02:12 PM   [ # 662 ]   [ Rating: 0 ]
Joined: 2008-11-26
148 posts

Hello,

I need some help.

How is it possible to write the following sql query with datamapper DMZ?

SELECT node.name, (COUNT(parent.name) - 1) AS depth
    FROM $this
->table AS node,
    
$this->table AS parent
WHERE node
.$this->left_column BETWEEN parent.$this->left_column AND parent.$this->right_column
GROUP BY node
.id
ORDER BY node
.$this->left_column

I’m particualry interested at the first 3 lines, where I select the same table AS alias.

Anyone has an idea?

The reason why I want to write this with DM is because I’m working on model extension which I’d like to make modular (without repeating the same sql code milion times accross diferent models that use Nested Sets)

Many thanks in advance!

 Signature 

Kundi

 
Posted: 04 October 2010 02:18 PM   [ # 663 ]   [ Rating: 0 ]
Joined: 2008-11-26
148 posts
WanWizard - 02 October 2010 07:08 PM

I had nested sets working, but I bined the idea. Way to many database queries when navigating through the tree.

I now use a class that reads the entire tree into memory (one single SELECT *), and then does everything else in memory. It uses Phil Sturgeon’s caching solution to cache the tree, which speeds things up even more…

Could you share this code with us, perhaps?

 Signature 

Kundi

 
Posted: 04 October 2010 03:48 PM   [ # 664 ]   [ Rating: 0 ]
Avatar
Joined: 2008-11-04
4489 posts

ExiteCMS is public, see our source browser. It’s in trunk/exitecms/classes.

We’re currently busy with a major rewrite, to Modular CI and Datamapper, so the version online is a bit dated, the rewrite happens in a private branch. It will be merged with the trunk when we’re finished, hopefully within a few weeks.

 Signature 

Me: WanWizard.eu | My company: Exite | Datamapper: DataMapper ORM <= LOOKING FOR A NEW MAINTAINER!

 
Posted: 05 October 2010 01:24 AM   [ # 665 ]   [ Rating: 0 ]
Avatar
Joined: 2009-06-13
94 posts

Alright, so right now in my controller I get an object using dmz. Let’s call it products:

$p = new Product();
$p->get();

Then I pass it to the view, and there loop through and find the reviews for each:

foreach($products as $product)
{
  $product->review->get();
}

Now this is obviously a simplified version. But basically, I need to loop through the products and get the associated reviews.

I need to do all of this in my controller. How can I do this there? How can I populate each individual record in the products object?

 
Posted: 05 October 2010 06:12 AM   [ # 666 ]   [ Rating: 0 ]
Joined: 2010-08-27
3 posts

Hi all.
Firstly, thanks for your Lib, this is a very good job wink.

I’m looking for setting avanced relationships between more than 2 tables, but don’t find a way to manage this natively with DMZ.

Consider this example.
4 tables: products / colors / sizes / types

1 product has one colors/sizes/types.

1 color has many sizes/types/products

1 size has many colors/types/products

1 type has many colors/sizes/products

In real life, there is more tables following theses relations.

Setting up relations with tables couples will be a pain, so the solution can be to create 1 global relations table like this:

table relations:

-id (auto-increment)
-
product_id
-size_id
-type_id
-color_id 

But i’m not sure how to configure (if it’s possible) DataMapper Models, even with advanced relationship, where the table “relations” can handle more than 2 relationships.

Of course, i can manage this manually with AR and joins, but i really like the way to instantiate and manage objects.

Ideas are welcome, thanks.

 
Posted: 05 October 2010 11:23 AM   [ # 667 ]   [ Rating: 0 ]
Joined: 2010-07-28
24 posts
tomdelonge - 05 October 2010 05:24 AM

Alright, so right now in my controller I get an object using dmz. Let’s call it products:

$p = new Product();
$p->get();

Then I pass it to the view, and there loop through and find the reviews for each:

foreach($products as $product)
{
  $product->review->get();
}

Now this is obviously a simplified version. But basically, I need to loop through the products and get the associated reviews.

I need to do all of this in my controller. How can I do this there? How can I populate each individual record in the products object?

$object->include_related($model, $fields = NULL, $prefix = TRUE, $instantiate = FALSE)

 
Posted: 06 October 2010 02:32 PM   [ # 668 ]   [ Rating: 0 ]
Joined: 2008-11-26
148 posts

Hello.

Is there any way to execute simple sql query without initializing new model object?

Lets say I just want to get single value from database, I dont want to waste a few lines of code and bunch of memory because of it..

Maybe something like:


$sql = “SELECT id FROM table WHERE name = ‘somename’”;
$id = $this->query($sql);

Any ideas?

 Signature 

Kundi

 
Posted: 06 October 2010 02:34 PM   [ # 669 ]   [ Rating: 0 ]
Avatar
Joined: 2008-10-08
1039 posts

@introvert
Just use the built-in CodeIgniter methods.  Using DMZ doesn’t prevent you from using CI.

Also, instantiating a single model doesn’t use up much memory.  Before you try to “optimize” your application, run some tests and see if there is any benefit.

 Signature 

Phil DeJarnett
  OverZealous Creations, LLC

 
Posted: 10 October 2010 07:57 PM   [ # 670 ]   [ Rating: 0 ]
Avatar
Joined: 2008-10-08
1039 posts

Important News Regarding DataMapper OverZealous Edition

Hello everyone,

As many of you might have noticed, I have not updated DMZ in quite some time (late March, in fact).  This has been mostly due to the fact that since then, I have been working full time at a new job, in a different state.  I really have not had a lot of time, and even if I did, I have been working off a small laptop.

Moving On…
In the last couple of weeks, I have started learning about Groovy and Grails, a dynamic scripting language built on top of the Java Virtual Machine, and a rapid web application development platform, respectively.  In reading about these tools, I have found excitement in developing that I have not had in some time.

This platform provides nearly all of the rapid-development potential of CodeIgniter, as well as the ability to write well-defined, strongly-typed code when needed.  It also has a large library of plugins, and many features that require a lot of hand-work to enable in CI.  Maybe most importantly, it has a very powerful ORM built-in, one that not only does everything that DMZ does, and more gracefully, but is significantly more flexible and can even build and update your database on-the-fly, based on the models.  There are so many features in Grails/GORM I always wanted to add to DMZ, but I never really found the time.

Many of my frustrations with CodeIgniter, such as the numerous bugs in the ActiveRecord library, poorly designed Session library, lack of built-in GET support, and various other issues, seem to be resolved in the Grails setup. This is probably because it is backed by frameworks that have been around for a while now, such as J2EE, Spring, and Hibernate.

For many of you, this may not be very interesting.  Because I run my own servers, I have the ability to install Java and a servlet engine as needed.  However, if you rely on a shared hosting plan, you will most likely not be able to use Java.  In fact, this was the very reason I started working with PHP and CodeIgniter in the first place.  (On that note: SliceHost is a great, low-cost way to get your own servers running.)

DMZ Can Live On!
What does this mean for DMZ?  In short, I’m looking to hand the reins over to someone else.  I haven’t used or worked on the library since late May.  It’s already going stale, with numerous outstanding bugs that I have no plans to correct.

Because DMZ is 100% open source, you don’t have to contact me if you don’t want.  However, I have extra materials and tools that I can pass on to anyone who’d like to make DMZ their own.

Please be aware that this is a large library, with a lot of complex code underneath.  It requires a pretty strong understanding of PHP’s magic functions (__get, __call), database design and management, and memory usage.  It also requires a bit of dedication, since the relatively small community around DMZ is highly active.

I really hope someone comes forward, and is willing to let DMZ live on.  (When I stopped working on the HTMLForm library I asked for a volunteer, but no one offered, and it has effectively died out for that reason.)

——-

So, please, if you are interested, I’ll happily ZIP up all of the content I have for DMZ, and send it over.  I’ll eventually be replacing the current DMZ URL with links to anyone who would like to host the manual and downloads.  (Please note, the current downloads are hard-coded in the manual to my website.  If you do decide to host it, a search-and-replace will probably be in order.)  If no one comes forward, I’ll upload the latest version to the CodeIgniter wiki, so it can still be downloaded.

Thank You,

 Signature 

Phil DeJarnett
  OverZealous Creations, LLC

 
Posted: 12 October 2010 01:37 PM   [ # 671 ]   [ Rating: 0 ]
Joined: 2009-05-30
17 posts

Sorry to hear this, Phil, but I completely understand.

Thanks for all the hard work you put into the library. Hopefully someone will be willing to take it on for you. I wish I had the time/php experience to do it.

 
Posted: 12 October 2010 07:02 PM   [ # 672 ]   [ Rating: 0 ]
Avatar
Joined: 2008-08-29
344 posts
OverZealous - 10 October 2010 11:57 PM

So, please, if you are interested, I’ll happily ZIP up all of the content I have for DMZ, and send it over.  I’ll eventually be replacing the current DMZ URL with links to anyone who would like to host the manual and downloads.  (Please note, the current downloads are hard-coded in the manual to my website.  If you do decide to host it, a search-and-replace will probably be in order.)  If no one comes forward, I’ll upload the latest version to the CodeIgniter wiki, so it can still be downloaded.

Thank You,

Not sure if ill have the time, but I plan to dive into some projects revolving around DMZ. I would be more than happy to host it, maybe get it going in a open svn where people can add their fixes as they find it.

I know there is a huge learning curve to maintaining this library so it may take some time.

Maybe there will be someone else that is more familiar or has the time. I can at least hold it out until that time happens.

Let me know

 Signature 

421 Entertainment :: YAAS - Yet Another Authentication System :: Error Logger :: DB Configs

 
Posted: 13 October 2010 05:36 AM   [ # 673 ]   [ Rating: 0 ]
Joined: 2008-08-25
25 posts

how do I use firephp in the model ???

 
Posted: 13 October 2010 07:17 AM   [ # 674 ]   [ Rating: 0 ]
Avatar
Joined: 2008-06-25
30 posts

Oh noes!

Thanks for all your work Phil, I have been using DMZ on a number of sites for the last year. I must admit, I thought the lack of recent updates was due to the fact that its was so stable!

I’ve been using DMZ in a CI CMS i’ve been developing and it works like a champ. I’m working on documentation right now so i can Open Source it. Pretty busy getting married at the mo so might not happen to soon!

I set up a GitHub repo for DMZ a while back http://github.com/th3hamburgler/Datamapper-DMZ If anyone has any fixes we can use this repo. Get in touch with a DM or through GitHub if anyone has any.

I’m not looking to take complete responsibility for DMZ as I can’t commit the time. An open Repo of some kind seems to make the most sense to keep this project going.

 Signature 

StuckTogetherWithTape

 
Posted: 13 October 2010 04:04 PM   [ # 675 ]   [ Rating: 0 ]
Avatar
Joined: 2008-08-29
344 posts
The Hamburgler - 13 October 2010 11:17 AM

I’m not looking to take complete responsibility for DMZ as I can’t commit the time. An open Repo of some kind seems to make the most sense to keep this project going.

I agree, we could setup some “leaders” but have an open project would be pretty cool.

 Signature 

421 Entertainment :: YAAS - Yet Another Authentication System :: Error Logger :: DB Configs

 
45 of 62
45