Open ddimazana22 opened 11 years ago
Hmm. Show your code =) and we try to help you. So I am using a Kohana PHP framework to make a web site application. In this framework used a php classes for validation and filtering data. I think there are many classes for it! Just use thay.
a sample listAction-function, with paging functionality: function getList($list){
$startIndex = 0;
$jtPageSize = 10;
if ($_REQUEST["jtStartIndex"]) $startIndex = $_REQUEST["jtStartIndex"];
if ($_REQUEST["jtPageSize"]) $jtPageSize = $_REQUEST["jtPageSize"];
if ($_REQUEST["jtSorting"]) $jtSorting = $_REQUEST["jtSorting"];
if($list=='depots'){
# prepare list-query
$sql = "SELECT \* FROM depots";
$sql.= " ORDER BY " . $jtSorting;
$sql.= " LIMIT " . $startIndex . "," . $jtPageSize . ";";
# get the data
$result = fn_sql_select($sql);
# Add all records to an array
$rows = array();
while ($row = fn_sql_fetch($result)) {
$rows[] = $row;
}
# count records from list-query
$sqlCount = "SELECT Count(_) FROM depots";
$result = fn_sql_select($sqlCount);
$Count = fn_sql_fetch($result);
}
if($rows!=null){
# Return result to jTable
$jTableResult = array();
$jTableResult['Result'] = "OK";
$jTableResult['Records'] = $rows;
$jTableResult['TotalRecordCount'] = $Count['Count(_)'];
}
else{
# Return result to jTable
$jTableResult = array();
$jTableResult['Result'] = "ERROR";
$jTableResult['Message'] = "No Data found.";
}
print json_encode($jTableResult);
}
you can do filtering by adding a WHERE-clause to the sql-query.
fn_sql_fetch($result);
You are used Pharen compiler for PHP or where did you get this function? What about SQL-injection protect? Using this function is dangerous!
this function fn_sql_fetch($result); is from our proper framework and is safe. it has some security features, and calls the mysql_fetch_array function.
Can anyone kindly provide PHP codes for the demos in the web site? I'm having trouble making it work, particularly validation and filtering.
Thanks in advance!