1. psmits
  2. RO CSVI
  3. Thursday, 01 December 2016
  4.  Subscribe via email
I am new to CSVI but I got it working, I can add records and update fields in my table
But in order to create a new record it is necessary to deliver a new record without a value for the field that has the primary key
How can I populate this field after the insertion with the proper value so it gets found by the primary key when I want to update it
I have tried with combining but that does not work
PHP version 7.0.13
Joomla! version 3.6.4
Database schema version 6.6.0
CSVI version 6.6.4.
Accepted Answer Pending Moderation
Hello,
Look at the following tests, if I leave the Type field empty, than the record is inserted !

Then the patch has worked. Let me explain again, when you set a import based on field, CSVI will check the table records with this import based on field value in your case it is Type with value R1 2020. Since there is a value set in import file, CSVI will always try to do an update. It doesn't actually check if the record exist for the given value. If you have an empty value, CSVI knows there is no such record and does an insert. Hope it is clear now.

Is this maybe caused by the change that was made ??

The patches have nothing to do with log entries.
Kind regards,

Tharuna

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory
  1. more than a month ago
  2. RO CSVI
  3. # 21
Accepted Answer Pending Moderation
Hi

I am sorry but before the change the record was also imported when both fields where empty !
See at my first test report test 8 !
It has improved the fact that now it does always insert the record if both fields are empty
Now test 9 from the first report does not fail
My question is from practical usage, how can you add a new record with all details required for a search ?????
E.g. if the search with the search field populated fails (test if the record exists )
It is not possible somehow to indicate that the record provided needs to be inserted ???
E.g. take a field that is not searched for, but indicates that an insert has to be done based on the primary key (which is empty in the supplied record "SeqNo";)
Maybe create a rule for that purpose ?
  1. more than a month ago
  2. RO CSVI
  3. # 22
Accepted Answer Pending Moderation
Hi

It appeared that the logs were present, my ftp program does not refresh the contents of the folder for some reason
So you can forget my remark about the log files
  1. more than a month ago
  2. RO CSVI
  3. # 23
Accepted Answer Pending Moderation
Hello,
how can you add a new record with all details required for a search ?????
E.g. if the search with the search field populated fails (test if the record exists )
It is not possible somehow to indicate that the record provided needs to be inserted ???

I would suggest you to leave import based on field to be empty so the primary key field of the table will be considered which is SeqNo in your table. In your import file leave SeqNo field empty. This way CSVI will do only insert of records.
Kind regards,

Tharuna

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory
  1. more than a month ago
  2. RO CSVI
  3. # 24
Accepted Answer Pending Moderation
Hi Tharuna

OK that will work but then I have to maintain different import files
And I also have to create a different template for maintaining existing records (changing the search field as well)
Otherwise the records will always be added

So no comfortable solution yet :(
Thanks for your help
  1. more than a month ago
  2. RO CSVI
  3. # 25
Accepted Answer Pending Moderation
Hi Tharuna

OK that will work but then I have to maintain different import files
And I also have to create a different template for maintaining existing records (changing the search field as well)
Otherwise the records will always be added

So no comfortable solution yet :(
Thanks for your help


Just tested with two seperate templates but same import file
That does work for me currently :)
I only have to take care that I do not forget to switch templates !
Thanks for your grate support.
  1. more than a month ago
  2. RO CSVI
  3. # 26
Accepted Answer Pending Moderation
Hello,
Yes, if you need to import based on two different fields then you need two different templates. Glad to know that your issues are solved.
Kind regards,

Tharuna

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory
  1. more than a month ago
  2. RO CSVI
  3. # 27
Accepted Answer Pending Moderation
Hi Tharuna

I was not 100 % happy with the fact that I needed to use two templates for maintaining my database
So I altered the included php to solve that issue
Now I only have one template that inserts or updates my database
It checks if the record does exist in the database, if not than the primary key is reset to its original
Than the record is inserted, if it already exist, then the database is updated
com_csvi\addon\com_csvi\model\import\custom.php
You might need to remove some of my log statements, or improve the code to meet your standards
Attachments (1)
  1. more than a month ago
  2. RO CSVI
  3. # 28
Accepted Answer Pending Moderation
Hello,
We are happy hear that you solved your issues by writing custom code but we are not going to use your code in our component as it is been developed for your requirement. I believe the reason you had two templates was because you had two different fields import based on fields and your custom code supports that. Again to be clear custom table import is purely based on only one field which is either primary key or import based on field. If this field value is set then CSVI is going to do an update and if the field value is empty then a record is inserted.
Kind regards,

Tharuna

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory
  1. more than a month ago
  2. RO CSVI
  3. # 29
Accepted Answer Pending Moderation
Hi Tharuna

No I do not have two different fields for the import !!
I use only one Field for that purpose, but with the standard program you need to create two templates
One for adding new records, and one for updating records
You cannot use one template to insert/update records
Hence with my modification, that is now possible with just one template
This template has the value for "ïmport based on field" set
That is a lot easier to setup and maintain
The behavior for an import without "import based on field" set is not changed
  1. more than a month ago
  2. RO CSVI
  3. # 30
Accepted Answer Pending Moderation
Hello,
I really don't understand why you had two templates for import. If its one field then one template should work. Can you send me your current template XML and your import file? To get template XML file got to CSVI maintenance page, Select CSVI Pro on first option and Backup template on second option. Select your template and click continue. Download the XML file and post it here.
Kind regards,

Tharuna

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory
  1. more than a month ago
  2. RO CSVI
  3. # 31
Accepted Answer Pending Moderation
Hi Tharuna

Included the import file and backup from my template
Attachments (1)
  1. more than a month ago
  2. RO CSVI
  3. # 32
Accepted Answer Pending Moderation
Hello,
So i had a looked into your template and import file. You have set import_based_on field to be Type and this field has value in import file because of which CSVI is always doing an update even when the record is not there. For CSVI to create new records, this value should be empty. Your changes to the PHP file will check for Type value in database and if it is not present will create a new record else it will update the existing record. did i understand it correct?
Kind regards,

Tharuna

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory
  1. more than a month ago
  2. RO CSVI
  3. # 33
Accepted Answer Pending Moderation
Hi Tharuna

Yes your assumption is correct, in case a search field is set, then it searches for it first.
If the record is not present it will add it. If the record is present than it will update the record found
If the record is not found than I set the primary key back to the one setup in the database
As the primary key is not present in my import the program inserts the record
  1. more than a month ago
  2. RO CSVI
  3. # 34
Accepted Answer Pending Moderation
Hello,
Ok, Thank you for confirming. I am working on changing the behaviour of import based on field so it acts independent from primary key field. If the value of import based on field is found in database then it will do a update else record will be inserted. I will send you a patch when it is ready.
Kind regards,

Tharuna

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory
  1. more than a month ago
  2. RO CSVI
  3. # 35
Accepted Answer Pending Moderation
Hi Tharuna

OK I will check your update to see if it does what I expect it to do
Thanks
  1. more than a month ago
  2. RO CSVI
  3. # 36
Accepted Answer Pending Moderation
Hello,
The patch file for import based on field to be independent of primary key field is ready. Can you try to load the attached patch file and see if it works as expected?

patch_custom_table_2017_01_31.zip
Attachments (1)
Kind regards,

Tharuna

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory
  1. more than a month ago
  2. RO CSVI
  3. # 37
Accepted Answer Pending Moderation
Hi Tharuna

I will test the patch this afternoon, I have to update my system with the latest version first
The patch is based on the latest version released ?
  1. more than a month ago
  2. RO CSVI
  3. # 38
Accepted Answer Pending Moderation
Hello,
Yes the files are based on the latest version. Let me know how it goes.
Kind regards,

Tharuna

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory
  1. more than a month ago
  2. RO CSVI
  3. # 39
Accepted Answer Pending Moderation
Hi Tharuna

I have tested your patch after installing the latest version
Now it works the same as my patch, so when a search field is set and the record is not present it will be inserted
I also tested for existing records to modify them
That does also work as expected

One question about updating CVSI
I noticed twice that after the update my import is not working
I have to save my template again without making changes to it
After that the import does work again
It gives a warning that the fields are not supported. I do not use predefined fields, I take them from the import file
See the image included


Error.jpg
Attachments (1)
  1. more than a month ago
  2. RO CSVI
  3. # 40
  • Page :
  • 1
  • 2
  • 3


There are no replies made for this post yet.
Be one of the first to reply to this post!