Radicore Forum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » RADICORE development » Bug Reports » Incorrect Autoinsert of created_date and created_user
Incorrect Autoinsert of created_date and created_user [message #2192] Tue, 07 July 2009 09:09 Go to next message
divico is currently offline  divico
Messages: 13
Registered: August 2008
Junior Member
Hi,
I get the following error:

Fatal Error: MySQL error: 1054 - Unknown column 'created_date' in 'field list' (# 1054).

SQL query: INSERT INTO spill_file SET ..., created_date='2009-07-07 13:24:26', created_user='...'

Error in line 866 of file '...\radicore\includes\dml.mysqli.class.inc'.

Error occurs in method insertRecord. As I could see the original $fieldarray passed to insertRecord is expanded through the foreach loop commented as "look for fields with 'autoinsert' option set". At runtime $this->fieldspec looks as follows:

Variable: fieldspec: (array)
Key: language_id Value: Array
Key1: type Value1: string
Key1: size Value1: 5
Key1: pkey Value1: y
Key1: required Value1: y
Key1: default Value1: EN
Key1: uppercase Value1: y
Key1: control Value1: dropdown
Key1: optionlist Value1: language_id
Key: language_name Value: Array
Key1: type Value1: string
Key1: size Value1: 40
Key1: required Value1: y
Key1: default Value1: English
Key1: nodisplay Value1: y
Key: created_date Value: Array
Key1: type Value1: datetime
Key1: size Value1: 20
Key1: required Value1: y
Key1: default Value1: 2000-01-01 00:00:00
Key1: autoinsert Value1: y
Key1: noedit Value1: y
Key1: nosearch Value1: y
Key: created_user Value: Array
Key1: type Value1: string
Key1: size Value1: 16
Key1: default Value1: UNKNOWN
Key1: autoinsert Value1: y
Key1: noedit Value1: y
Key1: nosearch Value1: y
Key: revised_date Value: Array
Key1: type Value1: datetime
Key1: size Value1: 20
Key1: autoupdate Value1: y
Key1: noedit Value1: y
Key1: nosearch Value1: y
Key: revised_user Value: Array
Key1: type Value1: string
Key1: size Value1: 16
Key1: autoupdate Value1: y
Key1: noedit Value1: y
Key1: nosearch Value1: y

The table I'm adding to is kind of a temporary nature and I do not have defined any of those columns. The error is caused by adding created_date and created_user to $fieldlist, which is not a defined column in my table.
I'm running version 1.48 and my last successful use of this function is probably a couple of months back. I added quite a few releases in between.

Kind regards, Divico
Re: Incorrect Autoinsert of created_date and created_user [message #2193 is a reply to message #2192] Wed, 08 July 2009 03:44 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2275
Registered: April 2006
Location: Surrey, UK
Senior Member
When you are using a table class it is absolutely imperative that the contents of $this->fieldspec correctly reflects the structure of the database table. The error you are seeing is because $this->fieldspec identifies a field which does not exist in the table, hence the SQL statement which is constructed will fail.

When you change the structure of any database table you *must* import the changed structure into the data dictionary, then export it to your application to rebuild the <table>.dict.inc file.

You say that this is a temporary table without any of those columns, so where did the contents of $this->fieldspec come from? If you modified $this->fieldspec to correspond with the table structure this error would not appear.


Re: Incorrect Autoinsert of created_date and created_user [message #2194 is a reply to message #2193] Wed, 08 July 2009 10:25 Go to previous messageGo to next message
divico is currently offline  divico
Messages: 13
Registered: August 2008
Junior Member
Hi Tony
The structure of the table has not been changed at all so there was no need to re-import the structure. I attach the <table>.dict.inc which was generated January 1st 2008 and still reflects the physical layout of the table.

My use case is as follows: I have 1:many relationship and based on the input provided at insert (add) of a record in the parent table I generate a series of records in the dependent table. I use the following code to do that:

...
Prepare records to be inserted in array $spill_file_fieldarray
...
$this->spill_file_obj = new spill_file;
$my_DML =& $this->spill_file_obj->_getDBMSengine($this->spill_file_obj- >dbms_engine, $this->spill_file_obj->dbname);
$my_DML->primary_key = array('monday_date','yahoo_symbol');
$this->ll_insert_spill_file($my_DML,"exchange","spill_file ",$spill_file_fieldarray);

function ll_insert_spill_file($mysql,$database,$table,$fieldarray)
{
foreach($fieldarray as $key=>$record)
{
$mysql->insertRecord($database,$table,$record);
}
}

Error occurs when I call insertRecord. None of my code actually references or even modifies fieldspec which is later used in dml.mysqli.class.inc. I have no clue how and at what point in time the fieldspec array is initialized with the values provided in my initial post (did not track that in the code so far). Are those values initialization values?

Also the code indicated above ran successful before. The last time I added a record to the parent table which triggered the insertRecord to the dependent table was January 18th 2009. I know this because I have a created_date column in the parent table. No code changes from my side since then. Unfortunately I don't know which version of radicore I ran early January.

Any help is appreciated,
Kind regards, Divico
Re: Incorrect Autoinsert of created_date and created_user [message #2195 is a reply to message #2194] Wed, 08 July 2009 10:42 Go to previous message
AJM is currently offline  AJM
Messages: 2275
Registered: April 2006
Location: Surrey, UK
Senior Member
Your original post stated that $this->fieldspec contained an entry for 'created_date', yet you now say that your <table>.dict.inc file does not refer to this field. This means that the contents of this->fieldspec is being modified at runtime *after* the contents of <table>.dict.inc has been loaded, so you need to step through with your debugger to see where it is happening.

Previous Topic: Small bug in include.xml.php5.inc
Next Topic: New Hosting Account Bug
Goto Forum:
  


Current Time: Mon Nov 29 18:47:26 EST 2021

Total time taken to generate the page: 0.01021 seconds