DMZ 1.7.1 (DataMapper OverZealous Edition) |
[eluser]introvert[/eluser]
Hello. I have a question regarding DMZ htmlform extension, which I know its not supported anymore but I'm stuck with it. I want to display a model form which has a related model and it's field is displayed normally with the listing of all items. Form name: some field some related model field (select box with items: related 1, related 2, etc.) I want to add option for "None" => 0 selection to it and I have no idea which would be the proper/best way to do this. I know about defining function get_htmlform_list in the model class but this wont return any array of data which I could manipulate to add the desired option/value. Is there any way to do this with the least effort/changes? Many thanks in advance.
[eluser]dejavu[/eluser]
Updated the select() method to better match the ActiveRecord version. ActiveRecord can accept an array or a string. Code: public function select($select = '*', $escape = NULL) I'm not exactly clear on what add_table_name is supposed to do. So although it's working perfectly for me, I can't say if it's the correct solution. If select really has to be a string, I had a second version that basically added if(is_array($select)) $select = implode(',',$select);
[eluser]Unknown[/eluser]
I have a table with a single primary integer key, but it is named "my_id", not "id" (for example). Can DataMapper be extended to support a primary integer key for a table which is NOT named "id"? It is limited for use with existing tables that do not have a field named "id" and cannot be changed because they are already core tables which are supporting an existing codebase. I have looked at the source code and see a lot of code that depends on the "id" property, especially in the relationship/join portions (where "id" is often hardcoded in the queries). However, if we could have an override (kind of like the $table property, perhaps called $id_name or something like that), which could be set on the model object, and used whenever referring to the primary ID key internally in the DMZ code, that would help a lot. Phil, I really like DMZ and thank you for maintaining and enhancing it. If you have any suggestions or thoughts about how this scenario can be handled, they are greatly appreciated!
[eluser]matyhaty[/eluser]
Hi All \Im wondering if anyone can help me, with what must be a simple issue!! I have a couple of tables... surveys surveytypes and they have a relationship, which get the table name: surveys_surveytypes This is all working well, and can save nicely. In the surveytypes tables is a very simple structure. Here are some made up entries: id = 1 title = 'type1' id = 2 title = 'Another name' All I want to be able to do is query the surveys table and get the surveytypes.title in the results Currently I have: Code: $st = new Survey(); which gets all the Survey information just fine. How do I get the surveytypes.title included in this? Many Thanks Matt
[eluser]dejavu[/eluser]
[quote author="matyhaty" date="1280805552"]Hi All \Im wondering if anyone can help me, with what must be a simple issue!! which gets all the Survey information just fine. How do I get the surveytypes.title included in this? Many Thanks Matt[/quote] Read the manual. include_related() is explained at http://www.overzealous.com/dmz/pages/get....Selection
[eluser]dejavu[/eluser]
[quote author="sixdimensionalarray" date="1280801917"]I have a table with a single primary integer key, but it is named "my_id", not "id" (for example). Can DataMapper be extended to support a primary integer key for a table which is NOT named "id"? It is limited for use with existing tables that do not have a field named "id" and cannot be changed because they are already core tables which are supporting an existing codebase. [/quote] I'm not sure. http://www.overzealous.com/dmz/pages/joi...join_field may do what you want, but you'll have to try it out to make sure.
[eluser]OverZealous[/eluser]
@sixdimensionalarray It is not possible to change the ID column. it must be id on the model tables, and <relationship>_id on join tables and ITFKs.
[eluser]patie[/eluser]
hi, i have a problem i need this query in DMZ.. Code: SELECT user.*, order.*, SUM((order_album.price)*order_album.quantity) AS price i have this : User $table='user'; $has_many = array('order'); Order var $table = 'order'; var $has_one = array('user'); var $has_many = array('order_album'); Order_album var $table = 'order_album'; var $has_one = array('order'); Code: $obj = new Order_album(); this works but i dont know how i join (in this "query") order.user_id with user.id - and dont order_album with user ... thanks for any help.
[eluser]WanWizard[/eluser]
Do I understand it correctly if I say that you have a many-to-many relationship between User and Order? In that case your relationship table, that links users to orders, MUST be called Order_users (name of both tables, alphabetical order). You then have two models, one for User and one for Order. You don't need a model for your relationship table. You then run the query like this: Code: $obj = new Order(); You update fields in the relationship table by using: Code: // Create objects
[eluser]patie[/eluser]
[quote author="WanWizard" date="1280951335"]Do I understand it correctly if I say that you have a many-to-many relationship between User and Order? In that case your relationship table, that links users to orders, MUST be called Order_users (name of both tables, alphabetical order). You then have two models, one for User and one for Order. You don't need a model for your relationship table. You then run the query like this: Code: $obj = new Order(); You update fields in the relationship table by using: Code: // Create objects User - Order i think it is not many-to-many because: one user have many orders but one order have only one user (user_id) i think it its one to many ? hmm |
Welcome Guest, Not a member yet? Register Sign In |