Fields Disappear

Discussion in 'Customization & add-ons' started by jamesw99, Sep 27, 2011.

  1. jamesw99

    jamesw99 New Member

    Joined:
    Sep 27, 2011
    Messages:
    3
    Hi guys,

    I'm trying to add custom fields, about 200 actually, which get updated with different user actions. Everything works perfectly until I add my 138th field. After that, all of the fields that I have added disappear from the list of added fields and the php functions that previously worked to update the fields in the mysql database no longer work.

    Can someone please tell me if this is a common error with a solution or not?

    And also, if there is a way to add a number of custom fields with default values for the user in the mysql database and have them actually work as if added through the 'add fields' function?

    Thanks,

    JW
  2. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    James,
    yes, there is limitation for number of fields in v3.
    However, I cannot believe you need 200 fields. I believe it can and it must be solved other way.
    Could you please describe your use case and provide sample of the fields? I will try to suggest you another solution.
  3. jamesw99

    jamesw99 New Member

    Joined:
    Sep 27, 2011
    Messages:
    3
    Hi Alex,

    So I'm trying to have approximately 190 fields per user. And these fields will all start with a value of 0 but change to 1 once the user has visited a particular page. For example, once the user has visited page1, the value of a field in the database will change to 1 and the user will then be shown page2 and so forth. I have also tried creating the exact type of field in the mysql database but it does not show up under fields and it does not behave the same way, ie, these fields do not get updated by my php scripts like the ones created in the user admin page do.

    Could you please help me with this?

    Thanks,

    JW
  4. davidm1

    davidm1 aMember User & Partner

    Joined:
    May 16, 2006
    Messages:
    4,437
    Sounds like you should be using an array in a single field.

    David
  5. jamesw99

    jamesw99 New Member

    Joined:
    Sep 27, 2011
    Messages:
    3
    Hi David,

    That sounds great. Could you tell me how to add an array field in amember please?
  6. davidm1

    davidm1 aMember User & Partner

    Joined:
    May 16, 2006
    Messages:
    4,437
    Use an SQL field set to blob. You then store data like this
    1,0,0,0
    so array(0) =1, meaning that they opened the 1st post
    and array(1) = 0, meaning they havent opened the 2nd post.
    and so on.

    David
  7. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    James, I'd also recommend to use separate table instead.
    For example
    PHP:
    <?php amDb()->query('CREATE TABLE ?_visits (member_id int not null, page_id int not null, unique (member_id, page_id))'); ?>
    then to check if user visited a page
    PHP:
    <?php
    $pageId 
    111// set current page id somehow, you know better
    if (amDb()->selectCell(
              
    "SELECT member_id FROM ?_visits 
               WHERE member_id=?d AND page_id=?d"
    ,
                
    $_SESSION['_amember_id'], $page_id))
    {
         exit(
    "You are already visited this page!");
    } else {  
    // mark current page as visited
         
    amDb()->query("INSERT IGNORE INTO ?_visits SET member_id=?d, page_id=?d",
              
    $_SESSION['_amember_id'], $page_id);
    }
    ?>
    and so on. It will be much more efficient than serialize/deserialize on each visit

Share This Page