Re: Storing arrays in the database (one field many values)

2012-11-09 Thread karthi

i need to move selected images to img/gallery/..i could able to select more 
than one images...instead more images there is only one image uploaded in 
that folder..is there a way to solve this issue..thanks in advance


echo $form-create('Image', array('action' = 'save' ,'type' = 
'file','multiple'='multiple'));
//echo $form-file('File');
echo $form-file('File', array('type' = 'file','multiple' = 
'multiple'));
echo $form-hidden(v_id,array 
(value=$this-data['Image']['v_id']));
echo $form-submit('Upload');
echo $form-end();

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: Storing arrays in the database (one field many values)

2009-08-11 Thread Rawna

Do I need to set foreign keys (author_id, book_id) to the tables
(books, authors)? How do I make my views have multiple selection
fields and how do I store them (because they're in an array)?

On Aug 7, 10:15 am, Robert P shiftyrobs...@gmail.com wrote:
 Well, if Books can have more than one Author in your system then it's:
     Authors hasAndBelongsToMany Books
     Books hasAndBelongsToMany Authors

 But if each book can only have one Author then it would be:
     Authors hasMany Books
     Book belongsTo Author

 with the foreign keys set up as required.

 Please read the Cookbook 
 -http://book.cakephp.org/view/78/Associations-Linking-Models-Together

 On Aug 7, 8:29 am,Rawnaasumaw...@gmail.com wrote:

  On Aug 7, 2:48 am, Vijay Kumbhar k.vidn...@gmail.com wrote:

   Better way please create new table that will take the book_id  the
   auther_id so that you can associate the models.

  What Model relationship should I do to create that? Could you please
  give an example?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Storing arrays in the database (one field many values)

2009-08-10 Thread CobaltShark

It is always a bad idea to try and squeeze lists into a single field.
It will inevitably lead to you pulling your hair out in the future.
Anyone who is tempted to store comma separated lists in a field
because its 'easier' should spend a few minutes reading about database
normalization. 
http://dev.mysql.com/tech-resources/articles/intro-to-normalization.html
is a great place to start. Following a few simple 'rules' when
developing your tables will save you the headache of trying to write
overly complex SELECT queries in the future.

On Aug 6, 2:19 am, Rawna asumaw...@gmail.com wrote:
 How do I store an array into the database?
 Here's the view:
                 echo $form-input('name');
                 echo $form-input('bio');
                 echo $form-input('book_id', array('multiple' = true));

 What if I got multiple books? How do I store them in the database?
 Whenever I tried saving the entry I get these errors:

 Notice (8): Array to string conversion
 Warning (512): SQL Error: 1054: Unknown column 'Array' in 'field list'
 Query: INSERT INTO `authors` (`name`, `bio`, `book_id`) VALUES ('Chuck
 Palahniuk', 'Great writer', Array)

 I created the BookController using bake BTW.

 Thanks in advance!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Storing arrays in the database (one field many values)

2009-08-10 Thread Martin Westin

I use serialization when:
1.
The array is a preference hash (used for settings in plugins). This is
a kind of caching to the db if you will.

2.
The array is a very complex or in some other way messy structure that
is only stored for logging purposes. One example is the rats-nest
called MM7 (SOAP xml-data for MMS services) and similar data that
would make up 70% of your database schema if stored in tables and
fields.

But I agree that is has major drawbacks if and when you find the need
to actually search through data stored this way.

/Martin


On Aug 10, 5:25 pm, CobaltShark cobaltsharksoftw...@gmail.com wrote:
 It is always a bad idea to try and squeeze lists into a single field.
 It will inevitably lead to you pulling your hair out in the future.
 Anyone who is tempted to store comma separated lists in a field
 because its 'easier' should spend a few minutes reading about database
 normalization.http://dev.mysql.com/tech-resources/articles/intro-to-normalization.html
 is a great place to start. Following a few simple 'rules' when
 developing your tables will save you the headache of trying to write
 overly complex SELECT queries in the future.

 On Aug 6, 2:19 am, Rawna asumaw...@gmail.com wrote:



  How do I store an array into the database?
  Here's the view:
                  echo $form-input('name');
                  echo $form-input('bio');
                  echo $form-input('book_id', array('multiple' = true));

  What if I got multiple books? How do I store them in the database?
  Whenever I tried saving the entry I get these errors:

  Notice (8): Array to string conversion
  Warning (512): SQL Error: 1054: Unknown column 'Array' in 'field list'
  Query: INSERT INTO `authors` (`name`, `bio`, `book_id`) VALUES ('Chuck
  Palahniuk', 'Great writer', Array)

  I created the BookController using bake BTW.

  Thanks in advance!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Storing arrays in the database (one field many values)

2009-08-07 Thread euromark (munich)

i wouldn't say that vijay was incorrect - he ment the same thing, just
didn't express it as clear as you, miles :)

either way it is way cleaner to normalize the database - this way you
have more control over the multiple choices
and if you delete one choice, you can make sure it is not related to
any record (with your arrays as serialized string this is not a nice
thing to do)


On 7 Aug., 04:15, Robert P shiftyrobs...@gmail.com wrote:
 Well, if Books can have more than one Author in your system then it's:
     Authors hasAndBelongsToMany Books
     Books hasAndBelongsToMany Authors

 But if each book can only have one Author then it would be:
     Authors hasMany Books
     Book belongsTo Author

 with the foreign keys set up as required.

 Please read the Cookbook 
 -http://book.cakephp.org/view/78/Associations-Linking-Models-Together

 On Aug 7, 8:29 am, Rawna asumaw...@gmail.com wrote:

  On Aug 7, 2:48 am, Vijay Kumbhar k.vidn...@gmail.com wrote:

   Better way please create new table that will take the book_id  the
   auther_id so that you can associate the models.

  What Model relationship should I do to create that? Could you please
  give an example?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Storing arrays in the database (one field many values)

2009-08-07 Thread euromark (munich)

well ok
serializing/unseriazing is still different than implode/explode
both are not very handy though

implode could be better if you want to search your in your pseudo
array with LIKE %{...}%

serializing if you dont want to do anything expect then saving/reading

hasMany or even HABTM as Robert stated would be the best choice in
most cases
especially as cake has beautiful automation for it anyway


On 7 Aug., 16:46, euromark (munich) dereurom...@googlemail.com
wrote:
 i wouldn't say that vijay was incorrect - he ment the same thing, just
 didn't express it as clear as you, miles :)

 either way it is way cleaner to normalize the database - this way you
 have more control over the multiple choices
 and if you delete one choice, you can make sure it is not related to
 any record (with your arrays as serialized string this is not a nice
 thing to do)

 On 7 Aug., 04:15, Robert P shiftyrobs...@gmail.com wrote:

  Well, if Books can have more than one Author in your system then it's:
      Authors hasAndBelongsToMany Books
      Books hasAndBelongsToMany Authors

  But if each book can only have one Author then it would be:
      Authors hasMany Books
      Book belongsTo Author

  with the foreign keys set up as required.

  Please read the Cookbook 
  -http://book.cakephp.org/view/78/Associations-Linking-Models-Together

  On Aug 7, 8:29 am, Rawna asumaw...@gmail.com wrote:

   On Aug 7, 2:48 am, Vijay Kumbhar k.vidn...@gmail.com wrote:

Better way please create new table that will take the book_id  the
auther_id so that you can associate the models.

   What Model relationship should I do to create that? Could you please
   give an example?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Storing arrays in the database (one field many values)

2009-08-06 Thread Vijay Kumbhar
You can not store array(); in the database.You have to separate the array
elements using implode function  then you can add it to the data base.

Better way please create new table that will take the book_id  the
auther_id so that you can associate the models.

On Thu, Aug 6, 2009 at 2:49 PM, Rawna asumaw...@gmail.com wrote:


 How do I store an array into the database?
 Here's the view:
echo $form-input('name');
echo $form-input('bio');
echo $form-input('book_id', array('multiple' = true));

 What if I got multiple books? How do I store them in the database?
 Whenever I tried saving the entry I get these errors:

 Notice (8): Array to string conversion
 Warning (512): SQL Error: 1054: Unknown column 'Array' in 'field list'
 Query: INSERT INTO `authors` (`name`, `bio`, `book_id`) VALUES ('Chuck
 Palahniuk', 'Great writer', Array)

 I created the BookController using bake BTW.


 Thanks in advance!

 



-- 
Thanks  Regards,
Vijayk.
Co-founder (www.weboniselab.com)

You Bring the Dreams, We'll Bring the Means

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Storing arrays in the database (one field many values)

2009-08-06 Thread Miles J

Vijay is slightly incorrect. You can serialize() an array and save it
as a text string in the database, and unserialize() when retrieving
the data.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Storing arrays in the database (one field many values)

2009-08-06 Thread Rawna

On Aug 7, 2:48 am, Vijay Kumbhar k.vidn...@gmail.com wrote:

 Better way please create new table that will take the book_id  the
 auther_id so that you can associate the models.

What Model relationship should I do to create that? Could you please
give an example?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Storing arrays in the database (one field many values)

2009-08-06 Thread Robert P

Well, if Books can have more than one Author in your system then it's:
Authors hasAndBelongsToMany Books
Books hasAndBelongsToMany Authors

But if each book can only have one Author then it would be:
Authors hasMany Books
Book belongsTo Author

with the foreign keys set up as required.

Please read the Cookbook - 
http://book.cakephp.org/view/78/Associations-Linking-Models-Together

On Aug 7, 8:29 am, Rawna asumaw...@gmail.com wrote:
 On Aug 7, 2:48 am, Vijay Kumbhar k.vidn...@gmail.com wrote:

  Better way please create new table that will take the book_id  the
  auther_id so that you can associate the models.

 What Model relationship should I do to create that? Could you please
 give an example?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---