Compound Key using Alias names not working
Compound Key using Alias names not working

Hi I am encountering a strange situation while inserting , editing and uploading a csv file to database using editor
1)
$editor = Editor::inst( $db, 'contract_return_bal_forecast', array('product_code', 'member_name') )
->fields(
Field::inst( 'contract_return_bal_forecast.product_code', 'product_code'),
when I use a alias name for the compound keys , while trying to insert the new data it shows primary key element is not available
however I am able to edit the data
2) when i use sth like this
$editor = Editor::inst( $db, 'contract_return_bal_forecast', array('product_code', 'member_name', 'start_date') )
->fields(
Field::inst( 'contract_return_bal_forecast.product_code'),
I am able to edit data, insert new data but when I try to insert data using CSV import file it does not read the fields associated with the compound keys , as shown in the figure below for product code. However, when using
Field::inst( 'contract_return_bal_forecast.product_code', 'product_code'), CSV Import seems to work fine and read all fields
Answers
The easiest way to fix this is to get rid of compound keys. They were popular in the 1980's and 1990's, I remember that. But they were always a terrible nightmare. Replace them with auto-increment ids if you can. Good luck!
Can you give me a link to your page an also show me your full PHP code please?
Allan
Hi
Before, My serverside code used to be like below. I wanted to have a primary key to be combination of three columns ('product_code', 'member_name', 'start_date') which will differentiate each row in table.
it is important to note, in case of the three keys used in code above
Field::inst( 'contract_return_bal_forecast.product_code', 'product_code')
Field::inst( 'contract_return_bal_forecast.member_name','member_name'),
Field::inst( 'contract_return_bal_forecast.start_date', 'start_date'),
using Alias names wont work and will give the error (primary key not found).
Now what I have done is , I have set these three columns to be unique in database using phpmyAdmin. and set up a new column
contract_id
as a auto increment primary key , as suggested by @rf1234 like in the code below and It is working now using alias names<?php
session_start();