why does the data only display the first column? my nestedData array is mounted wrong?

why does the data only display the first column? my nestedData array is mounted wrong?

mjesusmjesus Posts: 13Questions: 4Answers: 0

...
$sql = "SELECT * FROM acao WHERE 1 = 1 ";
$sql .= $filter;
$sql .=" ORDER BY " . $columns[$requestData['order'][0]['column']] . " " . $requestData['order'][0]['dir'] . " LIMIT " . $requestData['start'] . " ," . $requestData['length'] . " ";// adding length
$query = $sqlite_db->query($sql) or die("Erro no sql: BF_acessoBdSqlite_acao.php: get acao");

$data = array();
foreach ($sqlite_db->query($sql) as $row) { // preparing an array
$nestedData=array();

    $nestedData[] = $row["ID"]; 
    $nestedData[] = $row["NOME"]; 
    $nestedData[] = $row["CMT"]; 
    $nestedData[] = $row["MRID"]; 

    $data[] = $nestedData; 

}
// Cria o objeto json: json_data

$json_data = array(
"draw" => intval( $requestData['draw'] ), // same number for every request/draw by clientside
"recordsTotal" => intval( $totalData ), // total number of records
"recordsFiltered" => intval( $totalFiltered ), // total number of records after searching
"data" => $data // searches the data according to search parameters, sort, column names
);

Answers

  • kthorngrenkthorngren Posts: 21,338Questions: 26Answers: 4,954

    See if this nest objects example helps. If not then use the browser's network inspector to get an example of the JSON response so we can see what your data structure looks like.

    Kevin

  • mjesusmjesus Posts: 13Questions: 4Answers: 0

    Thanks Kevin. I'll try to examine the json response as soon as I get access to the machine I'm running it on.

  • mjesusmjesus Posts: 13Questions: 4Answers: 0

    I was able to inspect the Assembled array and it's really only assembling information in the first column when that's the id. Can you give me any tips on what I'm doing wrong?

  • mjesusmjesus Posts: 13Questions: 4Answers: 0

    ... My filter...

    $filter = "";
    if( !empty($requestData['search']['value']) ) {
    $filter .=" AND (id LIKE '" . $requestData['search']['value'] . "%' ";
    $filter .=" OR nome LIKE '" . $requestData['search']['value'] . "%' ";
    $filter .=" OR cmt LIKE '" . $requestData['search']['value'] . "%' ";
    $filter .=" OR mrid LIKE '" . $requestData['search']['value'] . "%' ) ";

        $sql           = "SELECT count(*) as x  FROM acao WHERE 1 = 1 "; 
        $sql          .= $filter;
        $query         = $sqlite_db->query($sql) or die("Com o search: BF_acessoBdSqlite_acao.php: get acao");
        $aux           = $query->fetch(PDO::FETCH_ASSOC);
        $totalFiltered = $aux["x"]; 
    

    }

Sign In or Register to comment.