Professional Web Applications Themes

#26177 [Com]: Can't store multiple variables in SHM - PHP Development

ID: 26177 Comment by: cunha17 at uol dot com dot br Reported By: l_faillie at yahoo dot com Status: Open Bug Type: Unknown/Other Function Operating System: Solaris 8 PHP Version: 4.3.3 New Comment: In fact, you should use an array if you want to store multiple information. Source 1 : storing variables $shm = shm_attach( 2710, 512); $data = array('val'=>'blabla', 'jour'=> date('D')); shm_put_var( $shm, 'data', serialize($data)); Source 2 : reading variables $shm = shm_attach( 2710, 512); $data = unserialize(shm_get_var($shm, 'data')); echo 'val :', $data['val'], "\n"; echo 'jour :', $data['jour'], "\n"; Previous Comments: ------------------------------------------------------------------------ [2003-11-08 10:06:05] l_faillie at yahoo dot com ...

  1. #1

    Default #26177 [Com]: Can't store multiple variables in SHM

    ID: 26177
    Comment by: cunha17 at uol dot com dot br
    Reported By: l_faillie at yahoo dot com
    Status: Open
    Bug Type: Unknown/Other Function
    Operating System: Solaris 8
    PHP Version: 4.3.3
    New Comment:

    In fact, you should use an array if you want to store multiple
    information.

    Source 1 : storing variables

    $shm = shm_attach( 2710, 512);
    $data = array('val'=>'blabla',
    'jour'=> date('D'));
    shm_put_var( $shm, 'data', serialize($data));


    Source 2 : reading variables

    $shm = shm_attach( 2710, 512);
    $data = unserialize(shm_get_var($shm, 'data'));
    echo 'val :', $data['val'], "\n";
    echo 'jour :', $data['jour'], "\n";


    Previous Comments:
    ------------------------------------------------------------------------

    [2003-11-08 10:06:05] l_faillie at yahoo dot com

    Description:
    ------------
    Hi all,

    It seems only one variable can be stored in a SHM zone.

    Reproduce code:
    ---------------
    Source 1 : storing variables

    $shm = shm_attach( 2710, 512);

    shm_put_var( $shm, 'val', 'blabla');
    shm_put_var( $shm, 'jour', date('D'));

    Source 2 : reading variables

    $shm = shm_attach( 2710, 512);
    echo 'val :', shm_get_var($shm, 'val'), "\n";
    echo 'jour :', shm_get_var($shm, 'jour'), "\n";

    Expected result:
    ----------------
    val :blabla
    jour :Sat

    Actual result:
    --------------
    val :Sat
    jour :Sat



    ------------------------------------------------------------------------


    --
    Edit this bug report at [url]http://bugs.php.net/?id=26177&edit=1[/url]
    cunha17 at uol dot com dot br Guest

  2. #2

    Default #26177 [Com]: Can't store multiple variables in SHM

    ID: 26177
    Comment by: cunha17 at uol dot com dot br
    Reported By: l_faillie at yahoo dot com
    Status: Open
    Bug Type: Unknown/Other Function
    Operating System: Solaris 8
    PHP Version: 4.3.3
    New Comment:

    oops! It seems that the second argument should be an integer:

    int shm_put_var ( int shm_identifier, int variable_key, mixed variable)


    Previous Comments:
    ------------------------------------------------------------------------

    [2003-11-08 12:49:26] l_faillie at yahoo dot com

    Yes it was my workaround but ... if it's the correct beaviour of this
    function, what is the usefullness of the second argument ?

    ------------------------------------------------------------------------

    [2003-11-08 12:42:22] cunha17 at uol dot com dot br

    In fact, you should use an array if you want to store multiple
    information.

    Source 1 : storing variables

    $shm = shm_attach( 2710, 512);
    $data = array('val'=>'blabla',
    'jour'=> date('D'));
    shm_put_var( $shm, 'data', serialize($data));


    Source 2 : reading variables

    $shm = shm_attach( 2710, 512);
    $data = unserialize(shm_get_var($shm, 'data'));
    echo 'val :', $data['val'], "\n";
    echo 'jour :', $data['jour'], "\n";

    ------------------------------------------------------------------------

    [2003-11-08 10:06:05] l_faillie at yahoo dot com

    Description:
    ------------
    Hi all,

    It seems only one variable can be stored in a SHM zone.

    Reproduce code:
    ---------------
    Source 1 : storing variables

    $shm = shm_attach( 2710, 512);

    shm_put_var( $shm, 'val', 'blabla');
    shm_put_var( $shm, 'jour', date('D'));

    Source 2 : reading variables

    $shm = shm_attach( 2710, 512);
    echo 'val :', shm_get_var($shm, 'val'), "\n";
    echo 'jour :', shm_get_var($shm, 'jour'), "\n";

    Expected result:
    ----------------
    val :blabla
    jour :Sat

    Actual result:
    --------------
    val :Sat
    jour :Sat



    ------------------------------------------------------------------------


    --
    Edit this bug report at [url]http://bugs.php.net/?id=26177&edit=1[/url]
    cunha17 at uol dot com dot br Guest

Similar Threads

  1. store variables in external files
    By polakemi webforumsuser@macromedia.com in forum Macromedia Flash Actionscript
    Replies: 6
    Last Post: February 1st, 11:32 PM
  2. #26177 [Opn->Bgs]: Can't store multiple variables in SHM
    By iliaa@php.net in forum PHP Development
    Replies: 0
    Last Post: November 10th, 04:15 AM
  3. #26177 [Opn]: Can't store multiple variables in SHM
    By l_faillie at yahoo dot com in forum PHP Development
    Replies: 0
    Last Post: November 8th, 05:51 PM
  4. #26177 [NEW]: Can't store multiple variables in SHM
    By l_faillie at yahoo dot com in forum PHP Development
    Replies: 0
    Last Post: November 8th, 03:08 PM
  5. Replies: 0
    Last Post: July 8th, 01:15 PM

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