Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
How store few objects in same row of db table
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  9 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Ivan Maximenko  
View profile  
 More options Oct 27 2012, 5:31 am
From: Ivan Maximenko <ivanmaxime...@gmail.com>
Date: Sat, 27 Oct 2012 02:31:28 -0700 (PDT)
Local: Sat, Oct 27 2012 5:31 am
Subject: How store few objects in same row of db table

Hello, Propel Users.

How in propel can be save aggregate object and аggregation object in same
row of db table.
Example, object "Product" aggregates "Attributes" and information about
both should be stored in same row of db table.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Manel Monguilod  
View profile  
 More options Oct 28 2012, 10:53 am
From: Manel Monguilod <ma...@monguilod.com>
Date: Sun, 28 Oct 2012 07:53:54 -0700 (PDT)
Local: Sun, Oct 28 2012 10:53 am
Subject: Re: How store few objects in same row of db table

Have you tried the aggregate_column behavior?
http://www.propelorm.org/behaviors/aggregate-column

El sábado, 27 de octubre de 2012 11:31:28 UTC+2, Ivan Maximenko escribió:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ivan Maximenko  
View profile   Translate to Translated (View Original)
 More options Oct 29 2012, 8:39 am
From: Ivan Maximenko <ivanmaxime...@gmail.com>
Date: Mon, 29 Oct 2012 05:39:12 -0700 (PDT)
Local: Mon, Oct 29 2012 8:39 am
Subject: Re: How store few objects in same row of db table

Sorry, but I do not understand how this behavior can solve this problem.

воскресенье, 28 октября 2012 г., 16:53:54 UTC+2 пользователь Manel
Monguilod написал:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Manel Monguilod  
View profile  
 More options Oct 30 2012, 7:23 am
From: Manel Monguilod <ma...@monguilod.com>
Date: Tue, 30 Oct 2012 04:23:52 -0700 (PDT)
Local: Tues, Oct 30 2012 7:23 am
Subject: Re: How store few objects in same row of db table

Hello Ivan,

probably I've not understand you problem correctly. What you want to save
exactly in the database? serialized objects? attributes of the product? Can
you provide a more detailed description?

Regards,

Manel

El lunes, 29 de octubre de 2012 13:39:12 UTC+1, Ivan Maximenko escribió:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ivan Maximenko  
View profile  
 More options Oct 30 2012, 8:18 am
From: Ivan Maximenko <ivanmaxime...@gmail.com>
Date: Tue, 30 Oct 2012 05:18:40 -0700 (PDT)
Local: Tues, Oct 30 2012 8:18 am
Subject: Re: How store few objects in same row of db table

For example table "Products" have columns "Id", "Name", "Size", "Color",
"Weight"
I want work with object product in such way:

$product = new Product();
$attrs = new ProductAttrs();
$attrs->fromArray(array("Weight" => '20', "Color" => "blue", "Size" =>
"XL"));
$product->setAttrs($attrs);
$product->save();

This is just example, in real application use another entities;

вторник, 30 октября 2012 г., 13:23:52 UTC+2 пользователь Manel Monguilod
написал:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Manel Monguilod  
View profile  
 More options Oct 31 2012, 6:57 am
From: Manel Monguilod <ma...@monguilod.com>
Date: Wed, 31 Oct 2012 03:57:27 -0700 (PDT)
Local: Wed, Oct 31 2012 6:57 am
Subject: Re: How store few objects in same row of db table

Ok. I understand the problem.

You can try with serialize an unserialize, or with json_encode and
json_decode and save the result as a varchar field o longvarchar depending
of the maximum size of data you want to save.

But be careful if the object that you are serializing has dependencies. For
instance, if your object is a Propel object, if you serialize and
unserialize in other session you can have problems retrieving related
objects.

El martes, 30 de octubre de 2012 13:18:40 UTC+1, Ivan Maximenko escribió:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Richtermeister  
View profile  
 More options Oct 31 2012, 11:51 pm
From: Richtermeister <nex...@gmail.com>
Date: Wed, 31 Oct 2012 20:51:59 -0700 (PDT)
Local: Wed, Oct 31 2012 11:51 pm
Subject: Re: How store few objects in same row of db table

Hey Ivan,

if you don't want to make the attributes fields on the product model
(because admins can add/remove attributes at will), you should probably
look into a so-called Entity-Attribute-Value setup, where you store
products, attributes, and attribute values each in different tables and
aggregate all this stuff when querying for products..
This is a bit complex but totally do-able.

You can also look into document-driven databases like MongoDB or CouchDB
where you can store whole objects.

Daniel


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ivan Maximenko  
View profile   Translate to Translated (View Original)
 More options Nov 1 2012, 4:33 am
From: Ivan Maximenko <ivanmaxime...@gmail.com>
Date: Thu, 1 Nov 2012 01:33:57 -0700 (PDT)
Local: Thurs, Nov 1 2012 4:33 am
Subject: Re: How store few objects in same row of db table

It's interesting idea, thanks for help.

четверг, 1 ноября 2012 г., 5:51:59 UTC+2 пользователь Richtermeister
написал:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Cristiano Cinotti  
View profile  
 More options Nov 1 2012, 9:06 am
From: Cristiano Cinotti <cristianocino...@gmail.com>
Date: Thu, 1 Nov 2012 14:06:12 +0100
Local: Thurs, Nov 1 2012 9:06 am
Subject: Re: [propel] Re: How store few objects in same row of db table
Hi Ivan,
if you can split your table into 2 tables, in that case Propel can
help you (see http://www.propelorm.org/documentation/04-relationships.html#onetoone...).

Ex:
in your schema.xml:

<table name="product">
  <column name="id" type="INTEGER" primaryKey="true" autoIncrement="true"/>
  <column name="name" type="VARCHAR" size="32"/>
</table>

<table name="attribute">
  <column name="product_id" type="INTEGER" primaryKey="true"/>
  <column name="size" type="VARCHAR" size="32"/>
  <column name="colour" type="VARCHAR" size="32"/>
  <foreign-key foreignTable="product">
    <reference local="product_id" foreign="id"/>
  </foreign-key>
</table>

Rebuild your model and now you can use your objects exactly as you whish:

$product = new Product();
$attr = new Attribute();
$attr->fromArray(array("Color" => "blue", "Size" => "XL"));
$product->setAttribute($attr);
$product->save();

Cheers
Cristiano


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »