
orafrijoles
Posts: 4
|
| Posted: 08/15/2005, 5:51 PM |
|
Hi there! i have little experience on CCS so i want to be assisted.
Here's my problem :
I'm using a record page to fill one table, two fields of this table are going to be inserted later in another table, an intermediate table that is. So i thought was a good idea to call an 'after insert event' on the server and make the two insertions on my intermediate table. Here's what i've tried :
function partidos_AfterInsert()
{
$partidos_AfterInsert = true;
global $partidos;
// Write your own code here.
$db = new clsRecordPartidos();
$SQL = "INSERT INTO partidos_has_equipos (par_clv,equ_clv) "
."VALUES (LAST_INSERT_ID(),".CCGetFromPost("par_eqlocal",0)."); "
. "INSERT INTO partidos_has_equipos (par_clv,equ_clv) "
."VALUES (LAST_INSERT_ID(),".CCGetFromPost("par_eqvisita",0)."); ";
$db->query($SQL);
$db->close();
//End Custom Code
return $partidos_AfterInsert;
}
I've tried changing several details in this part of the code yet not finding the correct. I get errors like 'undefined function query()' that means that $db var is not a valid connection object. I also wonder what global $partidos variable means...
I've seen many examples on this forum but i can't get to fix my code.
I hope someone can help me here. Thanks.
_________________
Sable y machete |
 |
 |
DonB
|
| Posted: 08/16/2005, 8:16 AM |
|
It should be clsDBRecordPartidos(), I believe. (note the addition of "DB" to
the name)
--
DonB
http://www.gotodon.com/ccbth
"orafrijoles" <orafrijoles@forum.codecharge> wrote in message
news:5430138ab078de@news.codecharge.com...
> Hi there! i have little experience on CCS so i want to be assisted.
> Here's my problem :
> I'm using a record page to fill one table, two fields of this table are
going
> to be inserted later in another table, an intermediate table that is. So i
> thought was a good idea to call an 'after insert event' on the server and
make
> the two insertions on my intermediate table. Here's what i've tried :
>
> function partidos_AfterInsert()
> {
> $partidos_AfterInsert = true;
>
> global $partidos;
> // Write your own code here.
> $db = new clsRecordPartidos();
> $SQL = "INSERT INTO partidos_has_equipos (par_clv,equ_clv) "
> ."VALUES (LAST_INSERT_ID(),".CCGetFromPost("par_eqlocal",0)."); "
> . "INSERT INTO partidos_has_equipos (par_clv,equ_clv) "
> ."VALUES (LAST_INSERT_ID(),".CCGetFromPost("par_eqvisita",0).");
";
>
> $db->query($SQL);
> $db->close();
>
> //End Custom Code
>
>
> return $partidos_AfterInsert;
> }
>
> I've tried changing several details in this part of the code yet not
finding
> the correct. I get errors like 'undefined function query()' that means
that $db
> var is not a valid connection object. I also wonder what global $partidos
> variable means...
>
> I've seen many examples on this forum but i can't get to fix my code.
> I hope someone can help me here. Thanks.
>
> _________________
> Sable y machete
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
|
|
|
 |
orafrijoles
Posts: 4
|
| Posted: 08/16/2005, 10:27 AM |
|
Yeah i found the problem !
I just pick up the db class created in the common.php and my new code look like this. Any suggestions are welcome :
global $partidos;
global $conexion;
$conexion = new clsDBtrinca();
// Write your own code here.
$last_id = mysql_insert_id(); // Obtiene el ultimo ID insertado en par_clv
// INICIO : rellenar partidos_has_equipos
$eqlocal = $partidos->ds->eq_local->GetValue();
$eqvisita = $partidos->ds->eq_visita->GetValue();
$sql = "INSERT INTO partidos_has_equipos ("
. "par_clv, "
. "equ_clv"
. ") VALUES (".$last_id.",".$conexion->ToSQL($eqlocal,ccsInteger). "); ";
$conexion->query($sql);
$sql = "INSERT INTO partidos_has_equipos ("
. "par_clv, "
. "equ_clv"
. ") VALUES (".$last_id.",".$conexion->ToSQL($eqvisita,ccsInteger). "); ";
if($conexion->Errors->Count() == 0) {
$conexion->query($this->SQL);
} else {
die ("Error al agregar partidos : ".mysql_error());
}
See ya
_________________
Sable y machete |
 |
 |
|

|
|
|
|