Professional Web Applications Themes

storing an array in a db - PHP Development

I know your first reaction will be "WHY?!?!" But can it be done? Can I store a php array in a postgresql database? -- Alexander Ross [email]alexrossbleen.net[/email]...

  1. #1

    Default storing an array in a db

    I know your first reaction will be "WHY?!?!" But can it be done? Can I store
    a php array in a postgresql database?

    --
    Alexander Ross
    [email]alexrossbleen.net[/email]


    Alexander Ross Guest

  2. #2

    Default Re: storing an array in a db

    On Thu, 07 Aug 2003 17:51:37 GMT, "Alexander Ross"
    <alexrossbleen.net> wrote:
    >I know your first reaction will be "WHY?!?!" But can it be done? Can I store
    >a php array in a postgresql database?
    Yes you can - but you'll have to explode the array first and put it
    into a suitable data structure.

    Still can't understand why though :)
    kafooey Guest

  3. #3

    Default Re: storing an array in a db

    Alexander Ross wrote:
    > I know your first reaction will be "WHY?!?!" But can it be done? Can I
    > store a php array in a postgresql database?
    >
    You can, given you store the data in a sensible fashion

    e.g.

    $storeary = array();
    foreach ($myarray as $myval)
    {
    $storeary[] = urlencode($myval);
    }
    $storestr = join('=', $storeary);

    on retrieval, you can explode('=', $retstr) and urldecode the values

    Alternatively, you could just have a separate table to store the array
    values in. It depends on what suits your application best
    matty Guest

  4. #4

    Default Re: storing an array in a db

    Hi Kafooey!

    On Thu, 07 Aug 2003 18:10:00 GMT, kafooey <kafooeyyahoo.co.uk> wrote:
    >On Thu, 07 Aug 2003 17:51:37 GMT, "Alexander Ross"
    ><alexrossbleen.net> wrote:
    >
    >>I know your first reaction will be "WHY?!?!" But can it be done? Can I store
    >>a php array in a postgresql database?
    >
    >Yes you can - but you'll have to explode the array first and put it
    >into a suitable data structure.
    >
    I would rather suggest to store it as a serialized object.
    >Still can't understand why though :)
    Example: i have a set of classes (see signature) that provide an easy
    edit interface to any amount of tables. Also, it creates a "filter
    block", where the user can filter by criteria on table fields.

    If I wanted to add saveable filters, I would store them as an array of
    the filter-criteria, serialized. This means I can have one table for
    saved filters, not as many as I have tables.

    HTh, Jochen


    --
    Jochen Daum - CANS Ltd.
    PHP DB Edit Toolkit -- PHP scripts for building
    database editing interfaces.
    [url]http://sourceforge.net/projects/phpdbedittk/[/url]
    Jochen Daum Guest

Similar Threads

  1. Why not storing
    By ChintuBabu in forum Macromedia Flash Flashcom
    Replies: 1
    Last Post: June 30th, 03:59 PM
  2. Database Storing
    By ocbeach in forum Macromedia Dynamic HTML
    Replies: 1
    Last Post: October 3rd, 04:20 PM
  3. Storing server side information into a javasript array
    By patb96 in forum Macromedia ColdFusion
    Replies: 1
    Last Post: May 26th, 12:48 AM
  4. Storing Slides
    By Carole in forum Photography
    Replies: 7
    Last Post: September 1st, 06:37 AM
  5. array data matches but array created in loop doesn't work
    By Reed Law in forum PHP Development
    Replies: 1
    Last Post: August 13th, 04:25 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139