We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 44718
    • 10 Posts
    Hi,

    I have a problem with xpdo and Blox. All the names are in dutch. So if you don't understand it let me know.

    I have an XPDO Schema like this:
    <object class="Clubprogramma" table="clubprogramma" extends="xPDOObject">
            <field key="ClubProgrammaID" dbtype="int" precision="11" phptype="integer" null="false" index="pk"  generated="native"/>
            <field key="Datum" dbtype="varchar" precision="11" phptype="string" null="false"/>
            <field key="Tijd" dbtype="varchar" precision="5" phptype="string" null="false"/>
            <field key="Thuis" dbtype="varchar" precision="300" phptype="string" null="false"/>
            <field key="Uit" dbtype="varchar" precision="300" phptype="string" null="false"/>
            <field key="Type" dbtype="varchar" precision="2" phptype="string" null="false"/>
            <field key="Accomodatie" dbtype="varchar" precision="300" phptype="string" null="false"/>
            <field key="Wedstrijdnr" dbtype="varchar" precision="6" phptype="string" null="false"/>
            <field key="Scheidsrechter" dbtype="varchar" precision="30" phptype="string" null="false"/>
            <field key="Status" dbtype="varchar" precision="30" phptype="string" null="false"/>
            <index alias="PRIMARY" name="PRIMARY" primary="true" unique="true" type="BTREE" >
    <column key="ClubProgrammaID" length="" collation="A" null="false" />
    </index>
        </object>


    And i have a blox call like this:

    [[!bloX? &packagename=`Soccer` &limit=`0` &classname=`Clubprogramma`
                                                                  &prefix=`voetbal_` &use_custom_prefix=`1`
    
    &tpls=`bloxouter:programHomeOuter||row:programHomeRow` &debug=`1`
    
    ]] 


    Now xpdo automatically makes an id field. But i have allready a table with fields in my database. So i don't want to get an id. Because now my blox-call don't work.

    Does anyone know what i have to do to get ClubProgrammaID as my primary key, so id field isn't loaded in my blox-call and i get all my information from my xpdo schema.

    Hope to hear from someone soon.

    Kevin

    This question has been answered by kevintje. See the first response.

    [ed. note: kevintje last edited this post 10 years, 8 months ago.]
      • 4172
      • 5,888 Posts
      may be bloX has issues with a primary-key other than id.

      Did it test with migxLoopCollection and this seems to work:

      [[!migxLoopCollection? 
          &packageName`soccer` 
          &limit=`0` 
          &classname=`Clubprogramma` 
          &prefix=`voetbal_`
          &placeholdersKeyField=`ClubProgrammaID`
          &tpl=`programHomeRow`
       ]]
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 44718
        • 10 Posts
        Maybe i do something wrong. But i don't get any results.

        [[!migxLoopCollection? 
            &packageName`Soccer` 
            &limit=`0` 
            &classname=`Clubprogramma` 
            &prefix=`voetbal_`
            &placeholdersKeyField=`ClubProgrammaID`
            &tpls=`programHomeRow`
            &debug=`0`
         ]]


        If i debug this loop i get this message:

        [2013-09-02 22:26:45] (ERROR @ /index.php)

        Could not load class: Clubprogramma from mysql.clubprogramma.
        [2013-09-02 22:26:45] (ERROR @ /index.php)

        Could not load class: Clubprogramma from mysql.clubprogramma.
        [2013-09-02 22:26:45] (ERROR @ /index.php)

        Clubprogramma::getSelectColumns() is not a valid static method.
        [2013-09-02 22:26:45] (ERROR @ /index.php)

        Could not load class: Clubprogramma from mysql.clubprogramma.
        [2013-09-02 22:26:45] (ERROR @ /index.php)

        Could not load class: Clubprogramma from mysql.clubprogramma.
        [2013-09-02 22:26:45] (ERROR @ /index.php)

        Could not load class Clubprogramma
        [2013-09-02 22:26:45] (ERROR @ /index.php)

        Could not load class: Clubprogramma from mysql.clubprogramma.
        [2013-09-02 22:26:45] (ERROR @ /index.php)

        Clubprogramma::loadCollection() is not a valid static method.
          • 4172
          • 5,888 Posts
          I just took this schema

          <?xml version="1.0" encoding="UTF-8"?>
          <model package="soccer" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM">
          <object class="Clubprogramma" table="clubprogramma" extends="xPDOObject">
                  <field key="ClubProgrammaID" dbtype="int" precision="11" phptype="integer" null="false" index="pk"  generated="native"/>
                  <field key="Datum" dbtype="varchar" precision="11" phptype="string" null="false"/>
                  <field key="Tijd" dbtype="varchar" precision="5" phptype="string" null="false"/>
                  <field key="Thuis" dbtype="varchar" precision="300" phptype="string" null="false"/>
                  <field key="Uit" dbtype="varchar" precision="300" phptype="string" null="false"/>
                  <field key="Type" dbtype="varchar" precision="2" phptype="string" null="false"/>
                  <field key="Accomodatie" dbtype="varchar" precision="300" phptype="string" null="false"/>
                  <field key="Wedstrijdnr" dbtype="varchar" precision="6" phptype="string" null="false"/>
                  <field key="Scheidsrechter" dbtype="varchar" precision="30" phptype="string" null="false"/>
                  <field key="Status" dbtype="varchar" precision="30" phptype="string" null="false"/>
                  <index alias="PRIMARY" name="PRIMARY" primary="true" unique="true" type="BTREE" >
          <column key="ClubProgrammaID" length="" collation="A" null="false" />
          </index>
              </object>
          
          </model>
          


          created a package-folder, created the schema-file and the table with MIGX-package-manager
          added some records
          and put the snippet-code above to a new resource and everything was working.

          Not sure if its a good idea to have the package-name starting uppercase.
          I have them allways lowercase.

          also, I think you will have less issues with a field named 'id' as the primary-key and extend
          xPDOSimpleObject


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

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
          • discuss.answer
            • 44718
            • 10 Posts
            Thanks for your time and answers!

            I reproduced the steps in your last reply, this works. I did this steps again with more tables, and it failed. It appears that some objects did not had the right schema, and the tables already existed in the db.

            I regenerated the schemas with xpdo schema generator and created a package (with a lowercase name). Works like a charm.

            Thanks for the quick help!

            Kevin