We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26503
    • 620 Posts
    I added a new field to a custom table in my modx database & am having trouble selecting data from it, the data just won't show up?!??

    - I added it to the schema & map files
    - I added it to the database [doh!]

    I can add items to the table and get that column populated so I'm 100% sure modx knows about the new field. however when I select:

    $attribs = $artistAttribs->getMany('ArtistAudio');
    					
    foreach ($attribs as $attrib) {
    						
    	$aarray = $attrib->toArray();
    	
    	$output .= $this->modx->getChunk('ArtistAudioRowTpl',$aarray);
    						
    }
    
    return $output;
    
    


    The ArtistAudioRowTpl does contain the new field [[+company]] and it is spelled the same in the database, map, and templates .... and there is data in the column. I have dumped the cache and deleted the cache files manually. I even restarted mysql thinking it may have cached the query somehow.

    No love, no joy anywhere.... I've added columns to tables like this before without problems.

    Any thoughts here? Did I maybe forget or miss updating a file??
      *** Not just websites, we also create signage, banners, print, trade show displays and more! ***

      Sean Kimball CLP, CLS.
      Technical Director / Sr. Developer | BigBlock Studios
      ._______________________________________________.
      Bigblock Studios http://www.bigblockstudios.ca Web site design & development.
      27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
      phone/fax: 905-426-5525
      • 22303 MODX Staff
      • 10,725 Posts
      What are the field details in the schema? Do they match the actual database field? Hard to say without more details...
        • 26503
        • 620 Posts
        Yes, they do - it's pretty straight forward, and like I said, modx CAN populate the new field, just does not seem to be able to select data from it [it will select all the other columns though!]

        The new field is the 'company' filed, and it does match the database....


        
        <?php
        $xpdo_meta_map['ArtistAudio']= array (
          'package' => 'extdata',
          'version' => '1.1',
          'table' => 'artist_audio',
          'extends' => 'xPDOSimpleObject',
          'fields' => 
          array (
            'artistkey' => 0,
            'label' => '',
            'location' => '',
            'bytes' => 0,
          ),
          'fieldMeta' => 
          array (
            'artistkey' => 
            array (
              'dbtype' => 'int',
              'precision' => '10',
              'phptype' => 'integer',
              'null' => false,
              'default' => 0,
            ),
            'label' => 
            array (
              'dbtype' => 'varchar',
              'precision' => '255',
              'phptype' => 'string',
              'null' => false,
              'default' => '',
            ),
            'location' => 
            array (
              'dbtype' => 'varchar',
              'precision' => '255',
              'phptype' => 'string',
              'null' => false,
              'default' => '',
            ),
            'bytes' => 
            array (
              'dbtype' => 'decimal',
              'precision' => '10,0',
              'phptype' => 'float',
              'null' => true,
              'default' => 0,
            ),
            'company' => 
            array (
              'dbtype' => 'varchar',
              'precision' => '255',
              'phptype' => 'string',
              'null' => true,
              'default' => '',
            ),
          ),
          'aggregates' => 
          array (
            'ArtistAttributes' => 
            array (
              'class' => 'ArtistAttributes',
              'local' => 'artistkey',
              'foreign' => 'id',
              'cardinality' => 'one',
              'owner' => 'foreign',
            ),
          ),
        );
        
        
          *** Not just websites, we also create signage, banners, print, trade show displays and more! ***

          Sean Kimball CLP, CLS.
          Technical Director / Sr. Developer | BigBlock Studios
          ._______________________________________________.
          Bigblock Studios http://www.bigblockstudios.ca Web site design & development.
          27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
          phone/fax: 905-426-5525
          • 22303 MODX Staff
          • 10,725 Posts
          Are you sure the map file got updated? That is the only thing I can think of...
            • 26503
            • 620 Posts
            positive - else how would I be able to populate the column? [also I checked it in a shell - yes]
              *** Not just websites, we also create signage, banners, print, trade show displays and more! ***

              Sean Kimball CLP, CLS.
              Technical Director / Sr. Developer | BigBlock Studios
              ._______________________________________________.
              Bigblock Studios http://www.bigblockstudios.ca Web site design & development.
              27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
              phone/fax: 905-426-5525
              • 22303 MODX Staff
              • 10,725 Posts
              Looking again at the map file, I see a problem: there is not in fact an entry in the fields array for 'company'. If you generated and updated the map files from the schema, it should be there. Did you update the map manually? If not, what does the field element for the company field look like in the schema?
                • 26503
                • 620 Posts
                sure there is... second last item in the array... ?
                  *** Not just websites, we also create signage, banners, print, trade show displays and more! ***

                  Sean Kimball CLP, CLS.
                  Technical Director / Sr. Developer | BigBlock Studios
                  ._______________________________________________.
                  Bigblock Studios http://www.bigblockstudios.ca Web site design & development.
                  27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
                  phone/fax: 905-426-5525
                  • 22303 MODX Staff
                  • 10,725 Posts
                  It's only showing inside the fieldMeta element, not the fields element:

                  array (
                      'artistkey' => 0,
                      'label' => '',
                      'location' => '',
                      'bytes' => 0,
                    ),
                  
                    • 26503
                    • 620 Posts
                    ? I must be looking at something wrong then - none of the columns are in the fields array.. right? [how is this thing working at all??]
                      *** Not just websites, we also create signage, banners, print, trade show displays and more! ***

                      Sean Kimball CLP, CLS.
                      Technical Director / Sr. Developer | BigBlock Studios
                      ._______________________________________________.
                      Bigblock Studios http://www.bigblockstudios.ca Web site design & development.
                      27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
                      phone/fax: 905-426-5525
                      • 3749
                      • 24,544 Posts
                      You might want to try the method outlined here: http://bobsguides.com/custom-db-tables.html

                      It will update the class and map files for you automatically.



                      ------------------------------------------------------------------------------------------
                      PLEASE, PLEASE specify the version of MODX you are using.
                      MODX info for everyone: http://bobsguides.com/modx.html
                        Did I help you? Buy me a beer
                        Get my Book: MODX:The Official Guide
                        MODX info for everyone: http://bobsguides.com/modx.html
                        My MODX Extras
                        Bob's Guides is now hosted at A2 MODX Hosting