EllisLab text mark
Advanced Search
51 of 63
51
   
DataMapper ORM v1.8.2
Posted: 27 September 2012 10:03 AM   [ Ignore ]   [ # 761 ]   [ Rating: 0 ]
Avatar
Joined: 2008-11-04
4404 posts
CI-Newb - 27 September 2012 07:23 AM

Just curious what’s the other php framework your a project lead for? publicly available?

Let’s keep this a CodeIgniter forum, before you know it a simple question like this ends in a ‘my framework is bigger then yours’ flame war… wink

 Signature 

Me: WanWizard.eu | My company: Exite | Datamapper: DataMapper ORM

 
Posted: 27 September 2012 10:05 AM   [ Ignore ]   [ # 762 ]   [ Rating: 0 ]
Avatar
Joined: 2008-11-04
4404 posts
rick20 - 27 September 2012 09:59 AM

Thanks a lot @WanWizard, I didnt think you will fix it so quick, thanks so much, man, I will give it a try.
And..wow…I can’t imagine even for a second, I’m in your position…got tons of responsibilities yet giving a lot of contributions to the communities, you really bring your life a priceless worth, man…
And, umm…don’t tell me you do that only for bandwidth..raspberry
I really wish you keep those great works up!
Thank you once more..

No, I stopped doing it for bandwidth a long time ago, but the nick and avatar stayed.

I do it for posts like this. Thanks! smile (Oh, and because it’s fun to do…)

 Signature 

Me: WanWizard.eu | My company: Exite | Datamapper: DataMapper ORM

 
Posted: 28 September 2012 03:46 PM   [ Ignore ]   [ # 763 ]   [ Rating: 0 ]
Joined: 2011-12-09
13 posts

Hello WanWizard.
I have just discovered one serious bug in self relationship model.
Here is the scenario: create absolute copy of this http://ellislab.com/forums/viewthread/196220/#923408 It wi.ll perfectly work. But if add new field named ‘organization’ (the same as model) - my local apache server will crash!
I’m sure that there is no need to fix that, but it need to be mentioned (maybe here http://datamapper.wanwizard.eu/pages/reservednames.html).

Best regards.

 Signature 

Thanks for DataMapper !!!

 
Posted: 29 September 2012 08:18 AM   [ Ignore ]   [ # 764 ]   [ Rating: 0 ]
Joined: 2012-01-22
15 posts

Hi WanWizard,


How would you formulate the query to get all objects of a specific class that don’t have a relationship with another class?

For examples, I have a class PERSON(id, firstname, lastname) that connects to EMPLOYMENT (id, start_date, end_date, person_id) which connects to COMPANY(id, company_name) using the table companies_employments(id, company_id, employment_id).

I want to be able to populate a list of all instances of PERSON that don’t have an EMPLOYMENT. (Forget about start and end_dates, I just want to see a list of person where there is no employment record for).

So in pseudo SQL : SELECT * FROM PERSON WHERE person.id NOT IN (array of all person_id in employment table)

 
Posted: 29 September 2012 05:17 PM   [ Ignore ]   [ # 765 ]   [ Rating: 0 ]
Avatar
Joined: 2008-11-04
4404 posts
smi23 - 28 September 2012 03:46 PM

Hello WanWizard.
I have just discovered one serious bug in self relationship model.
Here is the scenario: create absolute copy of this http://ellislab.com/forums/viewthread/196220/#923408 It wi.ll perfectly work. But if add new field named ‘organization’ (the same as model) - my local apache server will crash!
I’m sure that there is no need to fix that, but it need to be mentioned (maybe here http://datamapper.wanwizard.eu/pages/reservednames.html).

I find it difficult to believe that some PHP code in a model class can crash your webserver.

And I don’t understand what you want added to the reserved names. “organisation” isn’t a reserved name.

 Signature 

Me: WanWizard.eu | My company: Exite | Datamapper: DataMapper ORM

 
Posted: 29 September 2012 05:18 PM   [ Ignore ]   [ # 766 ]   [ Rating: 0 ]
Avatar
Joined: 2008-11-04
4404 posts
AAtticus - 29 September 2012 08:18 AM

Hi WanWizard,


How would you formulate the query to get all objects of a specific class that don’t have a relationship with another class?

http://datamapper.wanwizard.eu/pages/troubleshooting.html#Relationships.NotRelated

 Signature 

Me: WanWizard.eu | My company: Exite | Datamapper: DataMapper ORM

 
Posted: 29 September 2012 06:31 PM   [ Ignore ]   [ # 767 ]   [ Rating: 0 ]
Joined: 2012-01-22
15 posts

Thanks WanWizard, normally I scout the manual to find this information but I must have missed it. Sorry to ask for support for something trivial and well documented!

 
Posted: 01 October 2012 02:48 AM   [ Ignore ]   [ # 768 ]   [ Rating: 0 ]
Joined: 2011-12-09
13 posts
WanWizard - 29 September 2012 05:17 PM

I find it difficult to believe that some PHP code in a model class can crash your webserver.

And I don’t understand what you want added to the reserved names. “organisation” isn’t a reserved name.

Well, local server called ‘Denwer’ can.smile
I mean, if the table in self-relationship model, like in http://ellislab.com/forums/viewthread/196220/#923408 will have the column named exactly like model name, then some error will happen while you trying to get some results (maybe memory exceeding or something).
I’ve spent a lot of time trying to figure this out, so I’d like to help others to avoid that.

 Signature 

Thanks for DataMapper !!!

 
Posted: 01 October 2012 04:42 AM   [ Ignore ]   [ # 769 ]   [ Rating: 0 ]
Avatar
Joined: 2008-11-04
4404 posts

There is no restriction for column names with relation to the current model.

As both columns and relationships are accessed through model object properties, it’s obvious that you can’t give a relationship the same name as a column. It will cause your relationship not to work, as column data has preference. The first echo of the value will show you what’s wrong, so I don’t think it’s much of an issue.

 Signature 

Me: WanWizard.eu | My company: Exite | Datamapper: DataMapper ORM

 
Posted: 02 October 2012 06:23 AM   [ Ignore ]   [ # 770 ]   [ Rating: 0 ]
Joined: 2012-01-22
15 posts

WanWizard,

How would you use datamapper to build a search query with optional search fields.

in plain PHP/SQL I would check all the fields for empty, and build the query incrementally with only non empty search fields.

Is something like this possible in datamapper?

 
Posted: 02 October 2012 06:43 AM   [ Ignore ]   [ # 771 ]   [ Rating: 0 ]
Avatar
Joined: 2008-11-04
4404 posts

You can do the same:

// some example code, do not do it like this!
$object = new Model_Object();
foreach (
$_POST) as $field => $value)
{
    
empty($value) or $object->where($field$value);
}

// run the query
$object->get(); 
 Signature 

Me: WanWizard.eu | My company: Exite | Datamapper: DataMapper ORM

 
Posted: 08 October 2012 09:44 AM   [ Ignore ]   [ # 772 ]   [ Rating: 0 ]
Joined: 2012-01-22
15 posts

I’m getting a really strange error.

I’ve consultants and companies in a database. Companies can be clients or companies that external consultants work for.

so Company has many Consultants.
so Consultant has one Company.

Now, I’m trying to create a Booking class where a Consultant is placed withing a Company for a specific period.

So Booking has one Consultant and one Company

And now Company has many Consultants and many Bookings
And now Consultant has one Company and many Bookings

in my database I have

consultant (idnamecompany_id)
company (idname)
booking(iddatetime_startdatetime_end)
bookings_consultants(idbooking_idconsultant_id)
bookings_companies(idbooking_idcompany_id

If I try

$cu = new Consultant();
$co = new Company();;

// ... build $cu and $co from post data

$b = new Booking();
$b->datetime_start // datetime post data
$b->datetime_end // datetime post data

$b->save(array($co$cu)); 

I get this warning:

A PHP Error was encountered

Severity
Warning

Message
Illegal offset type in isset or empty

Filenamelibraries/datamapper.php

Line Number
4315 

And this Error:

Error Number1054

Unknown column 
'consultant_id' in 'where clause'

SELECT FROM (`bookings_companies`) WHERE `booking_id` = 42 AND `consultant_id` = 115

Filename
: /var/www/testapp/libraries/datamapper.php

Line Number
4990 

* If I remove the direct link between Consultants and Companies it works but then I don’t know which consultants work for which companies.

* why is it looking for a consultant_id in bookings_companies ? The link between consultants and bookings is in bookings_consultants.

 

 
Posted: 09 October 2012 01:31 AM   [ Ignore ]   [ # 773 ]   [ Rating: 0 ]
Joined: 2012-01-24
23 posts

@AAtticus, does the $cu and $co already saved to database after building them from POST data?
AFAIK when saving the relationship, datamapper need to know the relation’s IDs.
As for the error, what if you use the following as alternative:

$b->save_consultant($cu);
$b->save_companies($co); 

hope that helps smile

 
Posted: 09 October 2012 03:53 AM   [ Ignore ]   [ # 774 ]   [ Rating: 0 ]
Avatar
Joined: 2012-10-02
71 posts

I am new to CodeIgniter and don’t know what is datamapper orm. Anyone has a tutorial or any link for beginner to understand this? thanks!

 
Posted: 09 October 2012 04:28 AM   [ Ignore ]   [ # 775 ]   [ Rating: 0 ]
Joined: 2012-01-24
23 posts

@ninjayan maybe you can start from the documentation http://datamapper.wanwizard.eu/
The documentation is clear enough to start writing codes with datamapper.
There’s also some examples here http://datamapper.wanwizard.eu/pages/examples.html

 
51 of 63
51