Datatable server side with Firebird
Datatable server side with Firebird
Hey all,
I try to convert the server-side script for mysql to Firebird.
Here is what I have actually :
```
<?php
require '_inc_config.php';
define("DBNAME", "C:\PATH");
define("DBUSER", "USER");
define("DBPASS", "MDP");
$dbh = ibase_connect(DBNAME, DBUSER, DBPASS) or die(_ERROR15.": ".ibase_errmsg());
/* Paging */
$sLimit = "";
if (isset($_POST['iDisplayStart'])) {
settype($iDislayStart, 'integer');
$iDisplayStart = $_POST['iDisplayStart'];
$iDisplayLength = $_POST['iDisplayLength'];
$sLimit = sprintf(" FIRST ".$iDisplayStart." SKIP ".$iDisplayLength);
}
/* Ordering */
$sOrder = "";
$sOrder = " ORDER BY AC_DATE_PREVU ";
/* Filtering */
$sWhere = "";
if (isset($_POST['sSearch']) != "") {
$sWhere = " WHERE (AC_NOM_ACTION LIKE ''%".$_POST['sSearch']."%'') ";
}
$sQuery = "SELECT r.AC_DATE_PREVU as AC_DATE_PREVU, r.AC_NOM_ACTION as AC_NOM_ACTION, r.AC_DETAIL as AC_DETAIL, r.AC_DATEFIN as AC_DATEFIN, (select lta_nom from listetypeaction where lta_code = r.AC_TYPEACTION) as AC_TYPEACTION, (select v_nom from vendeur where v_code = r.AC_CODEINTERLOCUTEUR_DEST) as AC_UTILISATEUR_DEST, r.AC_CODECONTACT as AC_CODECONTACT from ACTIONS r".$sWhere.$sOrder.$sLimit.";";
$rResult = ibase_query($sQuery)or die(ibase_errmsg());
$sQuery = "SELECT COUNT(*) from (".$sQuery.$sWhere.$sLimit.");";
$rResultFilterTotal = ibase_query($sQuery); // 34
$aResultFilterTotal = ibase_fetch_assoc($rResultFilterTotal); // 36
$iFilteredTotal = $aResultFilterTotal[0];
$sQuery = "SELECT COUNT(*) as DCOUNT from ACTIONS";
$rResultTotal = ibase_query($sQuery) or die(_ERROR30 . ' (<small> </small>) : ' . ibase_errmsg());
$aResultTotal = ibase_fetch_assoc($rResultTotal);
$iTotal = $aResultFilterTotal[$sQuery];//$aResultTotal[0];
$sOutput = '{';
// $sOutput .= '"sEcho": '.intval($_POST['sEcho']).',';
$sOutput .= '"iTotalRecords": '.$iTotal.', ';
$sOutput .= '"aaData": [ ';
while ($aRow = ibase_fetch_assoc($rResult)) {
$sOutput .= "[";
$sOutput .= '"'.addslashes($aRow['AC_NOM_ACTION']).'",';
$sOutput .= '"'.addslashes($aRow['AC_TYPEACTION']).'",';
$sOutput .= '"'.addslashes($aRow['AC_UTILISATEUR_DEST']).'",';
$sOutput .= '"'.addslashes($aRow['AC_DATE_PREVU']).'",';
$sOutput .= '"'.addslashes($aRow['AC_DETAIL']).'"';
$sOutput .= "],";
}
$sOutput = substr_replace($sOutput, "", -1);
$sOutput .= '] }';
echo $sOutput;
function fnColumnToField( $i )
{
if ( $i == 0 )
return "AC_NOM_ACTION";
else if ( $i == 1 )
return "AC_TYPEACTION";
else if ( $i == 2 )
return "AC_UTILISATEUR_DEST";
else if ( $i == 3 )
return "AC_DATE_PREVU";
else if ( $i == 4 )
return "AC_DETAIL";
}
ibase_free_result($aResultTotal);
<?php
>
```
?>
But I've this two errors :
Warning: ibase_query(): Dynamic SQL Error SQL error code = -104 Token unknown - line 1, column 409 ; in C:\wamp\testServerSide.php on line 34
Warning: ibase_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\wamp\testServerSide.php on line 36
I wrote the lines on my code, it's easier for you.
Any ideas?
Thanks a lot,