Using Recordset returned by Execute() method

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
PauetValencia
User
Posts: 11

Using Recordset returned by Execute() method

Post by PauetValencia »

Hello everyone

I expose my problem, I'm doing the following script, the Query looks perfect but I can not see the result it returns !! that I'm doing wrong ... I've tried almost everything ....

Can you help me?

function ListOptions_Rendered() {


$tablaMatriz = $GET['showmaster'];
if ($tablaMatriz=='CasaAcogida'){
$idCasaAcogida = $
GET['ididCasaAcogida'];
$sSql = 'SELECT count(*) as total FROM CasaAcogida, DatosPersonales WHERE CasaAcogida.ididCasaAcogida=DatosPersonales.refExpediente and CasaAcogida.ididCasaAcogida='.$idCasaAcogida;
$rs=$GLOBALS["conn"]->execute($sSql);
echo "<br> Total2: ".$rs->fields->total;


return TRUE;


}

Thank you!!


mobhar
User
Posts: 11702

Post by mobhar »

Please read "Server Events and Client Scripts" topic from PHPMaker Help menu, then see the example in "ListOptions_Load" and "ListOptions_Rendered" section for your reference how to display the result in the certain custom column that you need to create.


kirondedshem
User
Posts: 642

Post by kirondedshem »

First read up on the help to know how to assign a value to a column using the ListOptions_Rendered().
I dont know what you wan to achive, After that some of the issues can be .
$rs=$GLOBALS["conn"]->execute($sSql);
If your sql returns a single value you can use ew_ExecuteScalar which executes a query and gives you the single scalar value, good for count(*), sum(column), and anything where you know the result will be a single values.
SO change line to
$my_value = ew_ExecuteScalar($sSql);
HINT: there is also ew_LoadRecordset, ew_ExecuteRows which you can use to read array of records etc etc

echo "<br> Total2: ".$rs->fields->total;
Echoing a vlaue here will not put it in the desired column, you need to specify which colmn of taht row or which list option you want to assing that value.
for example.to assing this value to a column called age of this row I would do:
$this->age->ViewValue = $my_value;


PauetValencia
User
Posts: 11

Post by PauetValencia »

Thanks a lot!

I post the last code

// ListOptions Rendered event
function ListOptions_Rendered() {
// Example:
//$this->ListOptions->Items["new"]->Body = "xxx";

// Ejecutamos esto si es Casa de Acogida


$tablaMatriz = $GET['showmaster'];
if ($tablaMatriz=='CasaAcogida'){
$idCasaAcogida = $
GET['ididCasaAcogida'];
echo "idCasaAcogida:".$idCasaAcogida;
$sSql = 'SELECT count(*) as total FROM CasaAcogida, DatosPersonales WHERE CasaAcogida.ididCasaAcogida=DatosPersonales.refExpediente and CasaAcogida.ididCasaAcogida='.$idCasaAcogida;
//echo var_dump($GLOBALS["conn"])."<br>";
$rs=ew_LoadRecordset($sSql);
echo "<br> Total: ".$rs->fields[0];



} // END IF TABLA MATRIZ
return TRUE;


}


Post Reply