swoole / ext-postgresql

🐘 Coroutine-based client for PostgreSQL
65 stars 21 forks source link

errorInfo attribute added (PDO-like) #19

Closed codercms closed 4 years ago

codercms commented 4 years ago

Examples:

^ Swoole\Coroutine\PostgreSQL {#4
  +error: """
    ERROR:  relation "test" does not exist\n
    LINE 1: SELECT 323r FROM test\n
                             ^\n
    """
  +errorInfo: array:3 [
    0 => "42P01"
    1 => 7
    2 => """
      ERROR:  relation "test" does not exist\n
      LINE 1: SELECT 323r FROM test\n
                               ^\n
      """
  ]
}
^ Swoole\Coroutine\PostgreSQL {#4
  +error: "ERROR:  prepared statement "some_1" does not exist\n"
  +errorInfo: array:3 [
    0 => "26000"
    1 => 7
    2 => "ERROR:  prepared statement "some_1" does not exist\n"
  ]
}
codercms commented 4 years ago

@twose this PR also fixes case that is prepare method is always returning true even if it actually fails