Error while doing a CSV import
Error while doing a CSV import
Description of problem: I am using DataTables Editor and while doing a CSV import, got the following error.
Error messages shown: A system error has occurred (More information).
From Chrome Develop Tool: Fatal error: Uncaught PDOException: There is no active transaction in /var/app/current/plugins/datatables/lib/Database/Query.php:198 Stack trace: #0 /var/app/current/plugins/datatables/lib/Database/Query.php(198): PDO->rollBack() #1 [internal function]: DataTables\Database\Query::rollback(Object(PDO)) #2 /var/app/current/plugins/datatables/lib/Database.php(314): call_user_func('DataTables\Data...', Object(PDO)) #3 /var/app/current/plugins/datatables/lib/Editor.php(707): DataTables\Database->rollback() #4 /var/app/current/plugins/Cyberator/views/controls_library-data.php(78): DataTables\Editor->process(Array) #5 {main} thrown in /var/app/current/plugins/datatables/lib/Database/Query.php on line 198
Could someone guide me on how to fix this issue? Thank you.
Answers
Does everything else work normally? Can you add, delete and modify records in the table?
Colin
Hi @colin,
Thanks for your response. Yes, everything else (add, delete and modify records) is working fine.
Can you show me the PHP code you are using for this please?
Thanks,
Allan
Hi Allan,
Sorry for the delay in posting the code snippet below:
Serverside code:
```
_<?php
include( "../../datatables/lib/DataTables.php" );
// Alias Editor classes so they are easy to use
use
DataTables\Editor,
DataTables\Editor\Field,
DataTables\Editor\Format,
DataTables\Editor\Mjoin,
DataTables\Editor\Options,
DataTables\Editor\Upload,
DataTables\Editor\Validate,
DataTables\Editor\ValidateOptions;
// Build our Editor instance and process the data coming from _POST
<?php >_ ``` Thank you! ?>Editor::inst( $db, 'org_controls_library' )
->fields(
Field::inst( 'id' ),
Field::inst( 'domain' ),
Field::inst( 'control_id' )
->validator( Validate::notEmpty( ValidateOptions::inst()
->message( 'Control ID is required' )
) ),
Field::inst( 'title' )
->validator( Validate::notEmpty( ValidateOptions::inst()
->message( 'Control Title is required' )
) ),
Field::inst( 'description' )
->validator( Validate::notEmpty( ValidateOptions::inst()
->message( 'Control Description is required' )
) ),
Field::inst( 'tags' ),
Field::inst( 'frequency' ),
Field::inst( 'level' )->set( Field::SET_CREATE )
)
->where( 'parent_uid', $_SESSION["parentid"] )
->on( 'preCreate', function ( $editor, $values ) {
$editor
->field('parent_uid')
->setValue($_SESSION["parentid"]);
} )
Hi @allan,
Do you see any error on the code that I posted above?
Thanks
There is nothing immediately obviously wrong there. How big is your CSV? Does it work if you just have one or two lines?
Just before the
->process($_POST)
call, could you add:what does the server then return?
Thanks,
Allan
Hi @allan,
Here are the responses to your question:
How big is your CSV? It has 114 lines
Does it work if you just have one or two lines? I tried it with 3 lines and that failed too.
I add your code before the ->process($_POST) call and it returned the following:
Fatal error: Uncaught PDOException: There is no active transaction in /var/app/current/plugins/datatables/lib/Database/Query.php:165
Stack trace:
commit()">commit()" href="#0-/var/app/current/plugins/datatables/lib/Database/Query.php(165):-PDO->commit()">0 /var/app/current/plugins/datatables/lib/Database/Query.php(165): PDO->commit()
1 [internal function]: DataTables\Database\Query::commit(Object(PDO))
2 /var/app/current/plugins/datatables/lib/Database.php(116): call_user_func('DataTables\Data...', Object(PDO))
commit()">commit()" href="#3-/var/app/current/plugins/datatables/lib/Editor.php(1040):-DataTables\Database->commit()">3 /var/app/current/plugins/datatables/lib/Editor.php(1040): DataTables\Database->commit()
_process(Array)">_process(Array)" href="#4-/var/app/current/plugins/datatables/lib/Editor.php(712):-DataTables\Editor->_process(Array)">4 /var/app/current/plugins/datatables/lib/Editor.php(712): DataTables\Editor->_process(Array)
process(Array)">process(Array)" href="#5-/var/app/current/plugins/Cyberator/views/controls_library-data.php(79):-DataTables\Editor->process(Array)">5 /var/app/current/plugins/Cyberator/views/controls_library-data.php(79): DataTables\Editor->process(Array)
6 {main}
thrown in /var/app/current/plugins/datatables/lib/Database/Query.php on line 165
Appreciate your help!!
Interesting! Nothing shown before that?
What does it return if you do this before your
Editor::inst(...)
:That will just select all from the table and show the array. It's just to check that there is a valid SQL db connection.
Thanks,
Allan
My data is showing as like this in jquery data table - https://prnt.sc/vxzy3r
But it not exporting fully field - https://prnt.sc/vxzzb5">https://prnt.sc/vxzzb5https://prnt.sc/vxzzb5
Kindly help to fix the issue. I need all values from the table to excel.
Thanks
@sbn111 We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin
@sbn111 - I'm not clear on how your post relates to the original question in this thread? If it is a different issue, could you open a new thread with a link to a test case showing the issue, and also a sample of the CSV you are using (assuming you are doing a CSV import) so we can figure out what is going on?
Thanks,
Allan
Hi @allan,
I added
print_r(
$db->select('org_controls_library', '*')->fetchAll()
);
before the code Editor::inst(...):When the page loads it throws this error:
DataTables warning: table id=example - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1
Have you followed the diagnostic steps in the technical note that's linked in the error message? That'll be the place to start,
Colin
Hello,
I have the exact same problem here, except the import works up to 47 lines.
Above this number of lines it throws the same transaction error.
Error
This error sounds to me like you reached some kind of limit on the server-side. Given that it works up to 47 rows, I'm thinking that it is probably a limit on the number of HTTP parameters that PHP has been configured with. What is your
max_input_vars
currently set to (usephpinfo()
if you aren't sure)?This article is quite good, relating to how to change it.
Allan