Not working for Big Database
Not working for Big Database

I got a database with 738.600 Rows and 20 ( + 1 uniqueID) columns.
This is my app.js and the error is "invalid JSON response".
If i manually set the LIMIT in the simple function from ssp.class.php to e.g. 0, 10000 i get data displayed, non paginated and non filterable, 10000 on one site.
If i manually open my webiste + getData.php i see blank page.
$(document).ready(function() {
$('#ItemList').DataTable({
"processing": true,
"serverSide": true,
"paging": true,
"ajax": {
"url": '../getData.php',
"dataSrc": 'data', //data because ssp.class.php adds data to it
"type": 'POST'
},
"columns": [
{ "data": 'Held' },
{ "data": 'Waffe' },
{ "data": 'Schild' },
{ "data": 'Ring' },
{ "data": 'Amulett' },
{ "data": 'Mantel' },
{ "data": 'Off' },
{ "data": 'OffT' },
{ "data": 'Def' },
{ "data": 'DefT' },
{ "data": 'Hybrid' },
{ "data": 'HybridT' },
{ "data": 'DefA' },
{ "data": 'DefAT' },
{ "data": 'OffA' },
{ "data": 'OffAT1' },
{ "data": 'OffAT2' },
{ "data": 'HybridA' },
{ "data": 'HybridAT1' },
{ "data": 'HybridAT2' },
{ "data": 'ExtraTruppen' }
]
});
});
And here my simple getData.php
<?php
require 'ssp.class.php';
$table = 'TABLENAME';
$primaryKey = 'ID';
$columns = array(
array( 'db' => 'Held', 'dt' => 'Held' ),
array( 'db' => 'Waffe', 'dt' => 'Waffe' ),
array( 'db' => 'Schild', 'dt' => 'Schild' ),
array( 'db' => 'Ring', 'dt' => 'Ring' ),
array( 'db' => 'Amulett', 'dt' => 'Amulett' ),
array( 'db' => 'Mantel', 'dt' => 'Mantel' ),
array( 'db' => 'Off', 'dt' => 'Off' ),
array( 'db' => 'OffT', 'dt' => 'OffT' ),
array( 'db' => 'Def', 'dt' => 'Def' ),
array( 'db' => 'DefT', 'dt' => 'DefT' ),
array( 'db' => 'Hybrid', 'dt' => 'Hybrid' ),
array( 'db' => 'HybridT', 'dt' => 'HybridT' ),
array( 'db' => 'DefA', 'dt' => 'DefA' ),
array( 'db' => 'DefAT', 'dt' => 'DefAT' ),
array( 'db' => 'OffA', 'dt' => 'OffA' ),
array( 'db' => 'OffAT1', 'dt' => 'OffAT1' ),
array( 'db' => 'OffAT2', 'dt' => 'OffAT2' ),
array( 'db' => 'HybridA', 'dt' => 'HybridA' ),
array( 'db' => 'HybridAT1', 'dt' => 'HybridAT1' ),
array( 'db' => 'HybridAT2', 'dt' => 'HybridAT2' ),
array( 'db' => 'ExtraTruppen', 'dt' => 'ExtraTruppen' )
);
$sql_details = array(
'user' => 'user',
'pass' => 'pass',
'db' => 'DATABASE',
'host' => 'localhost'
);
echo json_encode(
SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns )
);
<?php
>
?>
This question has accepted answers - jump to:
This discussion has been closed.
Answers
What is the server returning if it isn't valid JSON. The tech note that the error message links to will tell you how to find that out.
Allan
Technote 1: did all the steps..
In console on firefox it does the ajax and nothing more no errors etc.
If i click on the ajax post i can see the send informations, if i check recieve its just empty. The request takes 5000 - 21000ms till the browser stops loading and showing a white page. I had the same issue on ngTable because it want to get all data at once. Another 8year old pagination table script loaded all the data.
EDIT: It seems to stop at ssp.class.php:236-242 at $data generation in simple()
i echo'ed $limit, $order and $where and all 3 are NULL so the SQL operation would be a simple get ALL from database or a FAIL cuz of the NULL.
MySQL: get 738,760 data in 0.0024 secs.
So this is the bottleneck i guess.
Echo'ed SQL command:
Try yourself: sanctuments.16mb.com/getData.php
here the head of the recieve:
Request:
POST
That's fine. An empty response is invalid JSON. The next step would be to check the server's error logs.
With what error?
Allan
no errors, its simply the last thing he does, if i do an echo after the function the echo wont be printed. maybe timeout from server and script keeps waiting? because for 10k data it takes 5-10sec if he tries to get the ~800.000 it would take minutes..
server error logs where to find
im new to web
Depends on the server. For apache on *nix it would normally be
/var/log/apache2/error_log
. But you'd need to check your server's configuration.It might be worth trying to echo out the SQL that is being run to make sure it looks sensible.
Allan
In my 2nd Post you can see the SQL that is echo'ed.
the NULL at the end makes problems also that there is no limit, i try check server log..
EDIT: i made 2 requests and its always the same error.
AS i thought the Scripts requests to much at once because the $LIMIT is unset
I can give you full Access to DB/Scripts or TeamViewer if u want to its 0 sensible xD
Sorry I missed the SQL. That isn't a server-side processing statement since there is no limit.
Does that actually implement server-side processing.
That would be covered under the priority support options.
Allan
My first post contains the getData.php tell me what is wrong as i cant find anything
Or has it something to do with the php memory limit of my hoster. It is set to 128Mb and the complete databse got 235MB? But that cant be as sone 8 year old script can handle it to create a sinple table with 3400 sites of paginating.
Clearly your PHP script is running out of memory.
Either use a smaller dataset for debugging, or increase available memory with ini_set().
Also (A) try your query in PhpMyAdmin, and (B) check your error log as already advised.
But:
You are POSTing the data, and then not using it! Change the
$_GET
to$_POST
.Allan
Omg thank you that was the problem
now i need to get style in it and custom filtering and it will be perfect.
Have being battling with this for days, my ssp return fine if the record in my table is within 10, but for a table of 500 and above the following line return blank
SSP::simple( $_POST, $sql_details, $table, $primaryKey, $columns )
I suspected the post parameters but i return it and they where completely ok,
I also echo $request ($request['start']) and it was live on ssp_class.php, so in my own case i dont think limit or where should be null, please i need help, what could be responsible?
Sounds like you have error reporting disabled in PHP. I'd suggest checking the server's error logs.
You could possibly also use:
to enable error reporting in your file.
Allan
Resolved, json_encode return blank because of invalid json, i just added charset=utf8 to my pdo connection and all was fine
Hey @pagolina, can you please explain exactly where you added the line? I believe I'm having the exact same issue but I'm not sure where to add the charset=utf8. I'm guessing it's somewhere near the following line..
echo json_encode(
SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns, )
);
Let me know thanks
This page might help, it's showing where to set it.
Colin