PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 20??, PHP 5.3.0
+- Added msg_queue_exists() function (Benjamin Schulz)
- Added 3 Firebird specific attributes that can be set via PDO::setAttribute()
to control formatting of date/timestamp columns: PDO::FB_ATTR_DATE_FORMAT,
PDO::FB_ATTR_TIME_FORMAT and PDO::FB_ATTR_TIMESTAMP_FORMAT.
PHP_FUNCTION(msg_set_queue);
PHP_FUNCTION(msg_send);
PHP_FUNCTION(msg_receive);
+PHP_FUNCTION(msg_queue_exists);
typedef struct {
key_t key;
PHP_FE(msg_remove_queue, NULL)
PHP_FE(msg_stat_queue, NULL)
PHP_FE(msg_set_queue, NULL)
+ PHP_FE(msg_queue_exists, NULL)
{NULL, NULL, NULL} /* Must be the last line in sysvmsg_functions[] */
};
/* }}} */
}
/* }}} */
+
+/* {{{ proto bool msg_queue_exists(int key)
+ Check wether a message queue exists */
+PHP_FUNCTION(msg_queue_exists)
+{
+ long key;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &key) == FAILURE) {
+ return;
+ }
+
+ if (msgget(key, 0) < 0) {
+ RETURN_FALSE;
+ }
+
+ RETURN_TRUE;
+}
+/* }}} */
+
+
/* {{{ proto resource msg_get_queue(int key [, int perms])
Attach to a message queue */
PHP_FUNCTION(msg_get_queue)
--- /dev/null
+--TEST--
+msg_queue_exists()
+--SKIPIF--
+<?php if (!extension_loaded("sysvmsg")) die("skip sysvmsg extension is not available")?>
+--FILE--
+<?php
+$id = ftok(__FILE__, 'r');
+
+msg_remove_queue(msg_get_queue($id, 0600));
+
+var_dump(msg_queue_exists($id));
+$res = msg_get_queue($id, 0600);
+var_dump($res);
+var_dump(msg_queue_exists($id));
+var_dump(msg_remove_queue($res));
+var_dump(msg_queue_exists($id));
+echo "Done\n";
+?>
+--EXPECTF--
+bool(false)
+resource(%d) of type (sysvmsg queue)
+bool(true)
+bool(true)
+bool(false)
+Done