We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 44298
    • 8 Posts
    Hello!

    I have a table

    And generated schema

    But when i try create new object and row like this:
    $iid = substr(md5(time()),0,7);
    $modx->log(xPDO::LOG_LEVEL_ERROR, $iid);
    $dateUpload = date('Y-m-d H:i:s');
    
    $manufacturer = isset($manufacturer)?$manufacturer:$customManufacturer;
    //Добавляем данные
      $row = $modx->newObject('Forms');
      $row->fromArray(array(
        'id' => $iid,
        'country' => $country,
        'section' => $section,
        'manufacturer' => $manufacturer,
        'comment' => $comment,
        'email' => $e_mail,
        'path2image' => $filename,
        'dateUpload' => $dateUpload
      ));
    $modx->log(xPDO::LOG_LEVEL_ERROR, $row->save());


    I find out no full query and trying to add empty id field by log like this:
     INSERT INTO `x_museum_forms` (`country`, `section`, `manufacturer`, `comment`, `email`, `path2image`, `dateUpload`) VALUES ('DZ', 'sec1', 'man2', 'cxv', '[email protected]', '201307119092013-07-10_18_01_56-open.png', '2013-07-11 09:09:41')
    Array
    (
        [0] => 23000
        [1] => 1062
        [2] => Duplicate entry '' for key 'PRIMARY'
    )
    


    WHY?))
      • 4172
      • 5,888 Posts
      your id-field should be autoincrementing.
      Then you can extend xPDOSimpleObject and remove the id-field and index-definitions for this field from your schema
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!