Hello, I have a PHP Api which executes various procedures in a Sql Anywhere 17 database. In some of the procedures "messages" are output via the "messsage" function. Is there a way to read these messages in PHP and display them in the frontend? I use the SqlAnywhere PHP extension.

I have already tried to solve it via the system procedure "sa_server_messages()" but unfortunately it is not possible to recognize which connection/user triggered the message.

P.s. I don't want to change the procedures with the messages because they are also used in a desktop application.

asked 08 Jan, 08:47

tbr-baehren's gravatar image

tbr-baehren
911210
accept rate: 0%


The procedure sa_server_messages only applies to messages written to the server console.

It sounds like you want message ... to client. This is available in embedded SQL and ODBC requiring a message callback to be registered.

For more information, see MESSAGE STATEMENT.

permanent link

answered 08 Jan, 11:58

Chris%20Keating's gravatar image

Chris Keating
7.7k49127
accept rate: 32%

Chris, I wonder whether the PHP API (which presumably is based on the SA C API, which offers the sqlany_register_callback() function) does support/offer those callbacks, too?

(09 Jan, 02:42) Volker Barth

Based on the PHP driver source in %sqlany17%\SDK\PHP, I am not able to find any invocations of sqlany_register_callback in the PHP driver implementation.

(09 Jan, 09:42) Chris Keating

Chris, so it is not possible to get these messages via PHP cause its not implemented in the driver right. Any ideas how i can provide those messages for users in a web application? Maybe i should add the message(s) as a result set to the procedure.

(12 Jan, 02:17) tbr-baehren
Replies hidden

so it is not possible to get these messages via PHP cause its not implemented in the driver right.

Well, technically the driver's source code is available in the SQL Anywhere installation (see Chris's comment), so in case you are familiar with C and PHP programming, you might be able to enhance the driver to add an according callback facility. My knowledge of PHP is rather limited, so I can't tell whether this is doable and how difficult this would be - AFAIK, PHP itself does support callback functions, and the underlying SQL Anywhere C API does provide that according sqlany_register_callback with type CALLBACK_MESSAGE, so there should be chances it will work.

That being said, it is probably way easier to enhance your stored procedures with according result sets...

(12 Jan, 04:15) Volker Barth
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×70
×2

question asked: 08 Jan, 08:47

question was seen: 142 times

last updated: 12 Jan, 04:15