Ejemplo n.º 1
0
 /**
  * Used to get the last error that happened
  *
  * @static should only be called statically, i.e. AutoCRUD_Error::get_last_error();
  * @return AutoCRUD_Error the last error
  */
 function &get_last_error()
 {
     $stack =& AutoCRUD_Error::stack();
     // No errors? return false
     if (count($stack) == 0) {
         $false = false;
         return $false;
     }
     $last_error =& $stack[count($stack) - 1];
     return $last_error;
 }
Ejemplo n.º 2
0
 /**
  * Used to check if a unique error happened
  *
  * @access public
  * @param string $keyname the name of a specific index
  * @return bool whether a unique error has happened or not
  */
 function unique_error($keyname = null)
 {
     $errno = AutoCRUD_Error::get_last_errno(2);
     $errmsg = AutoCRUD_Error::get_last_errmsg(2);
     // No unique error?
     if ($errno != 1062) {
         return false;
     }
     // No keyname?
     if (!isset($keyname)) {
         return true;
     }
     // Parse key
     $split = explode(' ', $errmsg);
     $key = $split[count($split) - 1];
     // Check if it's a valid index
     if (!isset($this->indexes[$key])) {
         $this->halt('invalid-index', 'Invalid index during unique error');
         return false;
     }
     // Check if they match
     if ($this->indexes[$key] != $keyname) {
         return false;
     }
     return true;
 }