ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:userguide:error_handling

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
v5:userguide:error_handling [2016/02/01 23:56] mnewnhamv5:userguide:error_handling [2018/06/27 16:18] (current) – function names starting with lowercase (#430) dregad
Line 44: Line 44:
 </code> </code>
  
--------------------------------------------------- +
-<WRAP right box info 300px> +
-Currently, the raiseErrorFn must be a function, not a class method. +
-</WRAP>+
 ===== Override Error Trap/Resume ===== ===== Override Error Trap/Resume =====
 In certain circumstances, it may be necessary to trap errors differently or override the normal error handling. The current error handler, which is stored in the class variable  ''raiseErrorFn'', can be temporarily replaced. In this example, we use that functionality to ignore a database error. In certain circumstances, it may be necessary to trap errors differently or override the normal error handling. The current error handler, which is stored in the class variable  ''raiseErrorFn'', can be temporarily replaced. In this example, we use that functionality to ignore a database error.
Line 70: Line 67:
 set_error_handler('ignoreErrorHandler'); set_error_handler('ignoreErrorHandler');
   
-$db->Execute('DROP INDEX index_that_might_not_exist');+$db->execute('DROP INDEX index_that_might_not_exist');
   
 /* /*
Line 78: Line 75:
 $db->raiseErrorFn = $saveErrorFn; $db->raiseErrorFn = $saveErrorFn;
  
 +</code>
 +
 +===== Using A Class Method =====
 +<code php>
 +class c
 +{
 + function e()
 + {
 + print "ERROR TRAP";
 + }
 +}
 +
 +$c = new c;
 +
 +$db->raiseErrorFn = array($c,'e');
 </code> </code>
  
Line 112: Line 124:
 try  try 
 {    {   
-    $db = NewADOConnection("oci8://scott:bad-password@mytns/");   +    $db = newADOConnection("oci8://scott:bad-password@mytns/");   
  
  
Line 143: Line 155:
  
  
-$c = NewADOConnection('mysql'); +$c = newADOConnection('mysql'); 
-$c->PConnect('localhost','root','','northwind');+$c->pConnect('localhost','root','','northwind');
  
-$rs=$c->Execute('select * from productsz'); ## invalid table productsz+$rs=$c->execute('select * from productsz'); ## invalid table productsz
  
 if ($rs)  if ($rs) 
Line 168: Line 180:
 include('tohtml.inc.php'); include('tohtml.inc.php');
  
-$c = NewADOConnection('mysql'); +$c = newADOConnection('mysql'); 
-$c->PConnect('localhost','root','','northwind');+$c->pConnect('localhost','root','','northwind');
  
-$rs=$c->Execute('select * from productsz'); #invalid table productsz');+$rs=$c->execute('select * from productsz'); #invalid table productsz');
  
 if ($rs)  if ($rs) 
v5/userguide/error_handling.1454367371.txt.gz · Last modified: 2017/04/21 11:39 (external edit)