CodeIgniter Forums
DMZ 1.7.1 (DataMapper OverZealous Edition) - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: DMZ 1.7.1 (DataMapper OverZealous Edition) (/showthread.php?tid=28550)



DMZ 1.7.1 (DataMapper OverZealous Edition) - El Forum - 12-16-2010

[eluser]OverZealous[/eluser]
@Spir
The complete documentation has always included with every full download of DMZ. The new DMZ host has copies of DMZ 1.7 or older.


DMZ 1.7.1 (DataMapper OverZealous Edition) - El Forum - 12-17-2010

[eluser]j0nxiest[/eluser]
Hi,

I’m trying to use ->get() on an DMZ Object with 8000+ rows in the DB.

When I execute $obj->get(); The server gives me a status 500 Internal server error.

When I limit the query with ->limit(2289), it works without erros, with limit 2290 it starts giving the error.

I tested with active record $this->db->get(‘table’) and it worked fine.

I also tried to execute 3 queries with limits and offsets, but still it gives errors.

I really dont know where to start looking for the problem, first i was sure it hasn’t got anything to do with the ORM, but when i tested with Active Record and it worked, im not so sure anymore.


DMZ 1.7.1 (DataMapper OverZealous Edition) - El Forum - 12-17-2010

[eluser]bonatoc[/eluser]
Maybe you should investigate more in your Apache (or server) config, and your PHP config as well (max memory, etc).

Personally I have no problem retrieving a large table's content (+64 000 entries).

Edit : Dumb fast response. Obviously if it works the classic way, the problem doesn't come form the server config. Doh...

Maybe the relationships in your DMZ models that could overflow the server's memory ?


DMZ 1.7.1 (DataMapper OverZealous Edition) - El Forum - 12-17-2010

[eluser]j0nxiest[/eluser]
The model that im trying to get, doesn't have any relationships defined, and it doesn't help even if i try to only select the "id" column of the objects, so it shouldn't be a memory issue. I got it working now when using a for loop with 1000 as the limit, but its an ugly solution cause now i have to make 9 queries to get all the data atm.


DMZ 1.7.1 (DataMapper OverZealous Edition) - El Forum - 12-17-2010

[eluser]j0nxiest[/eluser]
Okay so i got it fixed. All my other tables are as InnoDB but this newly created table i forgot to change and it defaulted to MyIsam. So after i changed it to InnoDB, no problem fetching all the records at once.


DMZ 1.7.1 (DataMapper OverZealous Edition) - El Forum - 12-17-2010

[eluser]OverZealous[/eluser]
Please see the get_iterated method. It's under Get (Alternatives), and is specifically designed for this situation. [strike]Also, try limiting your selections - if you don't need every column, them don't load every column.[/strike] - Apparently you tried that.

Finally, if you are loading 8K rows into memory in a web app, you are most likely doing something wrong.


DMZ 1.7.1 (DataMapper OverZealous Edition) - El Forum - 12-17-2010

[eluser]bonatoc[/eluser]
Cool. But odd, my tables use MyISAM with no problem.

I suppose DMZ tables should be using the recommended engine, if any. Keep in mind that there is :

- The MySQL default engine setting (in the mysql config file)
- The DB default engine setting

After installing DMZ demo MySQL tables, it's not automatic that newly created tables are conforming to DMZ requirements (if any).
Also, I personally set the default charset as :

Encoding : UTF-8 Unicode (utf8)
Collation : utf8_general_ci

This may be of interest, even if unrelated to your problem :
http://philsturgeon.co.uk/news/2009/08/UTF-8-support-for-CodeIgniter

You may have to do some cleaning by building your own loop PHP scripts using utf8_encode and such, for updating columns containing text, if you're migrating from already populated tables using a different encoding (ISO-8859 or other).

http://paulkortman.com/2009/07/24/mysql-latin1-to-utf8-conversion/

With a dedicated server, you may as well declare your specific site via htaccess : this allows you to keep sites using other encodings on the same webserver untouched.

http://www.askapache.com/htaccess/setting-charset-in-htaccess.html


DMZ 1.7.1 (DataMapper OverZealous Edition) - El Forum - 12-18-2010

[eluser]WanWizard[/eluser]
For Datamapper, there is no difference to which MySQL engine you use. Even not which database you use, as it's using CI's database and AR libraries to interact with the database.

Datamapper creates a result object for each result in the resultset. If you load 8K results, it means you have 8K objects in memory. Depending on your PHP or script settings, and everything else you do, this can cause an out-of-memory situation.

As already mentioned, If you have a resultset this big, consider reviewing your logic, this is an indication of a design problem...


DMZ 1.7.1 (DataMapper OverZealous Edition) - El Forum - 12-26-2010

[eluser]MelloMike[/eluser]
I'm banging my head over a query looping problem and I could really use some help. Here's the query i have so far:

Code:
$u = new User();
        
$u->select('id, username, coordinates, updated');
$u->include_related('profile');
$u->limit(25);
$u->get();

This works fine when I just want to pull each user and their related profile. However.. the profile model has_many images. How can I pull in all the images?

I tried adding:
Code:
$u->include_related('profile/image');

But that won't work because include_related works with has_one and not has_many. So How can I pull all the images related to the profile which is related to the user? Is this possible?


DMZ 1.7.1 (DataMapper OverZealous Edition) - El Forum - 12-26-2010

[eluser]matyhaty[/eluser]
Hey there....

Try something along the line of:

Code:
$u->profile->image->get();

From there you could do:

Code:
foreach(u->profile->image as $profileImage)
{
   echo $profileImage->filename;
}

Also, I personally use this when doing 'include related' so i can access like '$u->image'.
Code:
$u->include_related('image', array('filename'), TRUE, TRUE);

Let us know how you get on.

Regards

Matt