Handled errors.
2011-11-11 17:42:55 GMT
Hello everybody, well:
I am working in an action in a manager inserting data in a table, in a foreach i am checking that every query is right(i mean foreign keys are correct for instance), so when a query is right it should be insert but when something is wrong in the query it shouldn't insert it, i just need add (concatenate)it to a variable and at the end of the foreach show what queries were wrong.
1.- It doesn't insert the wrong queries, queries right are inserted(this is fine).
2.- if there is a query right after a wrong query it doesn't insert it(wrong), only insert queries righst that are before one wrong query is find.
how can i get the errors and continue with the foreach without complications(insert queries right after queries wrong) and at the end just show as a message the queries that weren't inserted.
i am trying to do this:
foreach( $grupos as $grupoi ) {
$insert="INSERT INTO PROGRAMACION_ESQ.EDUC_GRUPOS (ID, GRUPO, PERIODO_ANIO_ID, MATERIAS_ID, INST_DEPTOS_CARRERAS_PLANES_ID, CANT_ALUMNOS, EMPLEADOS_ID) VALUES ($idn, '$grupon', $peranioId, $materiaId, $planId, $alumnos, $empleadoId)";
$dbh->Execute($insert);
$success = false;
if ($dbh->Affected_Rows() > 0)
$success = true;
if ($success !== false) {
SGL::raiseMsg('Se insertaron los datos correctamente ', false, SGL_MESSAGE_INFO);
} else {
$insert.="\n";
//SGL::raiseError($insert, SGL_ERROR_NOAFFECTEDROWS);
}
}
$output->xml=$insert;
You don't care about how can i get the values from the insert, the problem is with the messages in the errors.
I don't want this large error, i want to show something like.
Fatal error: Uncaught exception 'ADODB_Exception' with message 'oci8
error: [2291: ORA-02291: integrity constraint
(PROGRAMACION_ESQ.EDUC_GRUPOS_FK1) violated - parent key not found] in
EXECUTE("INSERT INTO PROGRAMACION_ESQ.EDUC_GRUPOS (ID, GRUPO,
PERIODO_ANIO_ID, MATERIAS_ID, INST_DEPTOS_CARRERAS_PLANES_ID,
CANT_ALUMNOS, EMPLEADOS_ID) VALUES (10, 'B', 8, 1, 1, 22, 596)")
' in /var/www/sii_dgest/lib/pear/adodb/adodb-exceptions.inc.php:78
Stack trace:
#0 /var/www/sii_dgest/lib/pear/adodb/adodb.inc.php(1040):
adodb_throw('oci8', 'EXECUTE', 2291, 'ORA-02291: inte...', 'INSERT INTO
PRO...', false, Object(ADODB_oci8))
#1 /var/www/sii_dgest/lib/pear/adodb/drivers/adodb-oci8.inc.php(843):
ADOConnection->_Execute('INSERT INTO PRO...', false)
#2
/var/www/sii_dgest/modules/estructuraeducativa/classes/Educ_GruposServiciosWebMgr.php(300):
ADODB_oci8->Execute('INSERT INTO PRO...')
#3 /var/www/sii_dgest/lib/SGL/Manager.php(251):
Educ_GruposServiciosWebMgr->_cmd_cliente(Object(SGL_Registry),
Object(SGL_Output))
#4 /var/www/sii_dgest/lib in
/var/www/sii_dgest/lib/pear/adodb/adodb-exceptions.inc.php on line 78
You received this message because you are subscribed to the Google Groups "Seagull PHP Framework General Group" group.
To post to this group, send email to seagull_general <at> googlegroups.com.
To unsubscribe from this group, send email to seagull_general+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/seagull_general?hl=en.
RSS Feed