Ich habe Fehler in der Datentabelle in Mongodb bitte geben Sie die Lösung ... Wenn jemand Referenz Quellcode senden Sie mir, es wird hilfreich für mich .............. .................................................. .................................................. .................................................. ................PHP mit mongodb datatable Fehler
Notice: Undefined index: iColumns in D:\xampp\htdocs\mongo\test3.php on line 47
Notice: Undefined index: sEcho in D:\xampp\htdocs\mongo\test3.php on line 129
{"sEcho":0,"iTotalRecords":9,"iTotalDisplayRecords":9,"aaData":[{"_id":
{"$id":"5936e5e783b236680c00002a"},"name":"Mitra","age":21,"gender":"M","course":"BTECH","marks":77}
Source Code:
<?php
mb_internal_encoding('UTF-8');
$database = 'university';
$collection = 'students';
/**
* MongoDB connection
*/
try{
// Connecting to server
$m = new MongoClient();
}catch(MongoConnectionException $connectionException){
print $connectionException;
exit;
}
$m_collection = $m->$database->$collection;
/**
* Define the document fields to return to DataTables (as in http://us.php.net/manual/en/mongocollection.find.php).
* If empty, the whole document will be returned.
*/
$fields = array();
// Input method (use $_GET, $_POST or $_REQUEST)
$input = & $_REQUEST;
/**
* Handle requested DataProps
*/
// Number of columns being displayed (useful for getting individual column search info)
$iColumns = $input['iColumns'];
// Get mDataProp values assigned for each table column
$dataProps = array();
for ($i = 0; $i < $iColumns; $i++) {
$var = 'mDataProp_'.$i;
if (!empty($input[$var]) && $input[$var] != 'null') {
$dataProps[$i] = $input[$var];
}
}
/**
* Filtering
* NOTE this does not match the built-in DataTables filtering which does it
* word by word on any field. It's possible to do here, but concerned about efficiency
* on very large collections.
*/
$searchTermsAny = array();
$searchTermsAll = array();
if (!empty($input['sSearch'])) {
$sSearch = $input['sSearch'];
for ($i=0 ; $i < $iColumns ; $i++) {
if ($input['bSearchable_'.$i] == 'true') {
if ($input['bRegex'] == 'true') {
$sRegex = str_replace('/', '\/', $sSearch);
} else {
$sRegex = preg_quote($sSearch, '/');
}
$searchTermsAny[] = array(
$dataProps[$i] => new MongoRegex('/'.$sRegex.'/i')
);
}
}
}
// Individual column filtering
for ($i=0 ; $i < $iColumns ; $i++) {
if ($input['bSearchable_'.$i] == 'true' && $input['sSearch_'.$i] != '') {
if ($input['bRegex_'.$i] == 'true') {
$sRegex = str_replace('/', '\/', $input['sSearch_'.$i]);
} else {
$sRegex = preg_quote($input['sSearch_'.$i], '/');
}
$searchTermsAll[ $dataProps[$i] ] = new MongoRegex('/'.$sRegex.'/i');
}
}
$searchTerms = $searchTermsAll;
if (!empty($searchTermsAny)) {
$searchTerms['$or'] = $searchTermsAny;
}
$cursor = $m_collection->find($searchTerms, $fields);
/**
* Paging
*/
if (isset($input['iDisplayStart']) && $input['iDisplayLength'] != '-1') {
$cursor->limit($input['iDisplayLength'])->skip($input['iDisplayStart']);
}
/**
* Ordering
*/
if (isset($input['iSortCol_0'])) {
$sort_fields = array();
for ($i=0 ; $i<intval($input['iSortingCols']) ; $i++) {
if ($input[ 'bSortable_'.intval($input['iSortCol_'.$i]) ] == 'true') {
$field = $dataProps[ intval($input['iSortCol_'.$i]) ];
$order = ($input['sSortDir_'.$i]=='desc' ? -1 : 1);
$sort_fields[$field] = $order;
}
}
$cursor->sort($sort_fields);
}
/**
* Output
*/
$output = array(
"sEcho" => intval($input['sEcho']),
"iTotalRecords" => $m_collection->count(),
"iTotalDisplayRecords" => $cursor->count(),
"aaData" => array(),
);
foreach ($cursor as $doc) {
$output['aaData'][] = $doc;
}
echo json_encode($output);
Was ist ein "datierbar"? Selbst das Tag auf der Frage sagt, dass dies "mehrdeutig" ist, da der Begriff für verschiedene Komponenten in verschiedenen Sprachen verwendet wird. Sie müssen genauer sein. –