mirror of
https://github.com/bdnugget/php-src.git
synced 2026-11-13 04:00:50 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
111b9ed64a |
No files matched your search
@@ -1,186 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2003 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.02 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_02.txt. |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: Marcus Boerger <helly@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "php.h"
|
||||
|
||||
#if DBA_INIFILE
|
||||
#include "php_inifile.h"
|
||||
|
||||
#include "libinifile/inifile.h"
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#define INIFILE_DATA \
|
||||
inifile *dba = info->dbf
|
||||
|
||||
#define INIFILE_GKEY \
|
||||
key_type ini_key = inifile_key_split((char*)key) /* keylen not needed here */
|
||||
|
||||
#define INIFILE_DONE \
|
||||
inifile_key_free(&ini_key)
|
||||
|
||||
DBA_OPEN_FUNC(inifile)
|
||||
{
|
||||
info->dbf = inifile_alloc(info->fp, info->mode == DBA_READER, info->flags&DBA_PERSISTENT TSRMLS_CC);
|
||||
|
||||
return info->dbf ? SUCCESS : FAILURE;
|
||||
}
|
||||
|
||||
DBA_CLOSE_FUNC(inifile)
|
||||
{
|
||||
INIFILE_DATA;
|
||||
|
||||
inifile_free(dba, info->flags&DBA_PERSISTENT);
|
||||
}
|
||||
|
||||
DBA_FETCH_FUNC(inifile)
|
||||
{
|
||||
val_type ini_val;
|
||||
|
||||
INIFILE_DATA;
|
||||
INIFILE_GKEY;
|
||||
|
||||
ini_val = inifile_fetch(dba, &ini_key, skip TSRMLS_CC);
|
||||
*newlen = ini_val.value ? strlen(ini_val.value) : 0;
|
||||
INIFILE_DONE;
|
||||
return ini_val.value;
|
||||
}
|
||||
|
||||
DBA_UPDATE_FUNC(inifile)
|
||||
{
|
||||
val_type ini_val;
|
||||
int res;
|
||||
|
||||
INIFILE_DATA;
|
||||
INIFILE_GKEY;
|
||||
|
||||
ini_val.value = val;
|
||||
|
||||
if (mode == 1) {
|
||||
res = inifile_append(dba, &ini_key, &ini_val TSRMLS_CC);
|
||||
} else {
|
||||
res = inifile_replace(dba, &ini_key, &ini_val TSRMLS_CC);
|
||||
}
|
||||
INIFILE_DONE;
|
||||
switch(res) {
|
||||
case -1:
|
||||
php_error_docref1(NULL TSRMLS_CC, key, E_WARNING, "Operation not possible");
|
||||
return FAILURE;
|
||||
default:
|
||||
case 0:
|
||||
return SUCCESS;
|
||||
case 1:
|
||||
php_error_docref1(NULL TSRMLS_CC, key, E_WARNING, "Key already exists");
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
DBA_EXISTS_FUNC(inifile)
|
||||
{
|
||||
val_type ini_val;
|
||||
|
||||
INIFILE_DATA;
|
||||
INIFILE_GKEY;
|
||||
|
||||
ini_val = inifile_fetch(dba, &ini_key, 0 TSRMLS_CC);
|
||||
INIFILE_DONE;
|
||||
if (ini_val.value) {
|
||||
inifile_val_free(&ini_val);
|
||||
return SUCCESS;
|
||||
}
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
DBA_DELETE_FUNC(inifile)
|
||||
{
|
||||
INIFILE_DATA;
|
||||
INIFILE_GKEY;
|
||||
int res = inifile_delete(dba, &ini_key TSRMLS_CC);
|
||||
|
||||
INIFILE_DONE;
|
||||
return (res == -1 ? FAILURE : SUCCESS);
|
||||
}
|
||||
|
||||
DBA_FIRSTKEY_FUNC(inifile)
|
||||
{
|
||||
INIFILE_DATA;
|
||||
|
||||
if (inifile_firstkey(dba TSRMLS_CC)) {
|
||||
char *result = inifile_key_string(&dba->curr.key);
|
||||
*newlen = strlen(result);
|
||||
return result;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
DBA_NEXTKEY_FUNC(inifile)
|
||||
{
|
||||
INIFILE_DATA;
|
||||
|
||||
if (!dba->curr.key.group && !dba->curr.key.name) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (inifile_nextkey(dba TSRMLS_CC)) {
|
||||
char *result = inifile_key_string(&dba->curr.key);
|
||||
*newlen = strlen(result);
|
||||
return result;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
DBA_OPTIMIZE_FUNC(inifile)
|
||||
{
|
||||
/* dummy */
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
DBA_SYNC_FUNC(inifile)
|
||||
{
|
||||
/* dummy */
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
DBA_INFO_FUNC(inifile)
|
||||
{
|
||||
return estrdup(inifile_version());
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: sw=4 ts=4 fdm=marker
|
||||
* vim<600: sw=4 ts=4
|
||||
*/
|
||||
@@ -1,598 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2003 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.02 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_02.txt. |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: Marcus Boerger <helly@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "php.h"
|
||||
#include "php_globals.h"
|
||||
#include "safe_mode.h"
|
||||
#include "php_network.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "inifile.h"
|
||||
|
||||
/* ret = -1 means that database was opened for read-only
|
||||
* ret = 0 success
|
||||
* ret = 1 key already exists - nothing done
|
||||
*/
|
||||
|
||||
/* {{{ inifile_version */
|
||||
char *inifile_version()
|
||||
{
|
||||
return "1.0, $Revision$";
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ inifile_free_key */
|
||||
void inifile_key_free(key_type *key)
|
||||
{
|
||||
if (key->group) {
|
||||
efree(key->group);
|
||||
}
|
||||
if (key->name) {
|
||||
efree(key->name);
|
||||
}
|
||||
memset(key, 0, sizeof(key_type));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ inifile_free_val */
|
||||
void inifile_val_free(val_type *val)
|
||||
{
|
||||
if (val->value) {
|
||||
efree(val->value);
|
||||
}
|
||||
memset(val, 0, sizeof(val_type));
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ inifile_free_val */
|
||||
void inifile_line_free(line_type *ln)
|
||||
{
|
||||
inifile_key_free(&ln->key);
|
||||
inifile_val_free(&ln->val);
|
||||
ln->pos = 0;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ inifile_alloc */
|
||||
inifile * inifile_alloc(php_stream *fp, int readonly, int persistent TSRMLS_DC)
|
||||
{
|
||||
inifile *dba;
|
||||
int fd = 0;
|
||||
|
||||
if (!readonly) {
|
||||
if (!php_stream_truncate_supported(fp)) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't truncate this stream");
|
||||
return NULL;
|
||||
}
|
||||
if (SUCCESS != php_stream_cast(fp, PHP_STREAM_AS_FD, (void*)&fd, 1)) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not cast stream");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
dba = pemalloc(sizeof(inifile), persistent);
|
||||
memset(dba, 0, sizeof(inifile));
|
||||
dba->fp = fp;
|
||||
dba->fd = fd;
|
||||
dba->readonly = readonly;
|
||||
return dba;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ inifile_free */
|
||||
void inifile_free(inifile *dba, int persistent)
|
||||
{
|
||||
if (dba) {
|
||||
inifile_line_free(&dba->curr);
|
||||
inifile_line_free(&dba->next);
|
||||
pefree(dba, persistent);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ inifile_key_split */
|
||||
key_type inifile_key_split(const char *group_name)
|
||||
{
|
||||
key_type key;
|
||||
char *name;
|
||||
|
||||
if (group_name[0] == '[' && (name = strchr(group_name, ']')) != NULL) {
|
||||
key.group = estrndup(group_name+1, name - (group_name + 1));
|
||||
key.name = estrdup(name+1);
|
||||
} else {
|
||||
key.group = estrdup("");
|
||||
key.name = estrdup(group_name);
|
||||
}
|
||||
return key;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ inifile_key_string */
|
||||
char * inifile_key_string(const key_type *key)
|
||||
{
|
||||
if (key->group && *key->group) {
|
||||
char *result;
|
||||
spprintf(&result, 0, "[%s]%s", key->group, key->name ? key->name : "");
|
||||
return result;
|
||||
} else if (key->name) {
|
||||
return estrdup(key->name);
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ etrim */
|
||||
static char *etrim(const char *str)
|
||||
{
|
||||
char *val;
|
||||
size_t l;
|
||||
|
||||
if (!str) {
|
||||
return NULL;
|
||||
}
|
||||
val = (char*)str;
|
||||
while (strchr(" \t\r\n", *val)) {
|
||||
val++;
|
||||
}
|
||||
l = strlen(val);
|
||||
while (l && (strchr(" \t\r\n", val[l-1]))) {
|
||||
l--;
|
||||
}
|
||||
return estrndup(val, l);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ inifile_findkey
|
||||
*/
|
||||
static int inifile_read(inifile *dba, line_type *ln TSRMLS_DC) {
|
||||
char *fline;
|
||||
char *pos;
|
||||
|
||||
inifile_val_free(&ln->val);
|
||||
while ((fline = php_stream_gets(dba->fp, NULL, 0)) != NULL) {
|
||||
if (fline) {
|
||||
if (fline[0] == '[') {
|
||||
/* A value name cannot start with '['
|
||||
* So either we find a ']' or we found an error
|
||||
*/
|
||||
pos = strchr(fline+1, ']');
|
||||
if (pos) {
|
||||
*pos = '\0';
|
||||
inifile_key_free(&ln->key);
|
||||
ln->key.group = etrim(fline+1);
|
||||
ln->key.name = estrdup("");
|
||||
ln->pos = php_stream_tell(dba->fp);
|
||||
efree(fline);
|
||||
return 1;
|
||||
} else {
|
||||
efree(fline);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
pos = strchr(fline, '=');
|
||||
if (pos) {
|
||||
*pos = '\0';
|
||||
/* keep group or make empty if not existent */
|
||||
if (!ln->key.group) {
|
||||
ln->key.group = estrdup("");
|
||||
}
|
||||
if (ln->key.name) {
|
||||
efree(ln->key.name);
|
||||
}
|
||||
ln->key.name = etrim(fline);
|
||||
ln->val.value = etrim(pos+1);
|
||||
ln->pos = php_stream_tell(dba->fp);
|
||||
efree(fline);
|
||||
return 1;
|
||||
} else {
|
||||
/* simply ignore lines without '='
|
||||
* those should be comments
|
||||
*/
|
||||
efree(fline);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
inifile_line_free(ln);
|
||||
return 0;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ inifile_key_cmp */
|
||||
/* 0 = EQUAL
|
||||
* 1 = GROUP-EQUAL,NAME-DIFFERENT
|
||||
* 2 = DIFFERENT
|
||||
*/
|
||||
static int inifile_key_cmp(const key_type *k1, const key_type *k2 TSRMLS_DC)
|
||||
{
|
||||
assert(k1->group && k1->name && k2->group && k2->name);
|
||||
|
||||
if (!strcasecmp(k1->group, k2->group)) {
|
||||
if (!strcasecmp(k1->name, k2->name)) {
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ inifile_fetch
|
||||
*/
|
||||
val_type inifile_fetch(inifile *dba, const key_type *key, int skip TSRMLS_DC) {
|
||||
line_type ln = {{NULL,NULL},{NULL}};
|
||||
val_type val;
|
||||
int res, grp_eq = 0;
|
||||
|
||||
if (skip == -1 && dba->next.key.group && dba->next.key.name && !inifile_key_cmp(&dba->next.key, key TSRMLS_CC)) {
|
||||
/* we got position already from last fetch */
|
||||
php_stream_seek(dba->fp, dba->next.pos, SEEK_SET);
|
||||
} else {
|
||||
/* specific instance or not same key -> restart search */
|
||||
/* the slow way: restart and seacrch */
|
||||
php_stream_rewind(dba->fp);
|
||||
inifile_line_free(&dba->next);
|
||||
}
|
||||
if (skip == -1) {
|
||||
skip = 0;
|
||||
}
|
||||
while(inifile_read(dba, &ln TSRMLS_CC)) {
|
||||
if (!(res=inifile_key_cmp(&ln.key, key TSRMLS_CC))) {
|
||||
if (!skip) {
|
||||
val.value = estrdup(ln.val.value ? ln.val.value : "");
|
||||
/* allow faster access by updating key read into next */
|
||||
inifile_line_free(&dba->next);
|
||||
dba->next = ln;
|
||||
dba->next.pos = php_stream_tell(dba->fp);
|
||||
return val;
|
||||
}
|
||||
skip--;
|
||||
} else if (res == 1) {
|
||||
grp_eq = 1;
|
||||
} else if (grp_eq) {
|
||||
/* we are leaving group now: that means we cannot find the key */
|
||||
break;
|
||||
}
|
||||
}
|
||||
inifile_line_free(&ln);
|
||||
dba->next.pos = php_stream_tell(dba->fp);
|
||||
return ln.val;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ inifile_firstkey
|
||||
*/
|
||||
int inifile_firstkey(inifile *dba TSRMLS_DC) {
|
||||
inifile_line_free(&dba->curr);
|
||||
dba->curr.pos = 0;
|
||||
return inifile_nextkey(dba TSRMLS_CC);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ inifile_nextkey
|
||||
*/
|
||||
int inifile_nextkey(inifile *dba TSRMLS_DC) {
|
||||
line_type ln = {{NULL,NULL},{NULL}};
|
||||
|
||||
/*inifile_line_free(&dba->next); ??? */
|
||||
php_stream_seek(dba->fp, dba->curr.pos, SEEK_SET);
|
||||
ln.key.group = estrdup(dba->curr.key.group ? dba->curr.key.group : "");
|
||||
inifile_read(dba, &ln TSRMLS_CC);
|
||||
inifile_line_free(&dba->curr);
|
||||
dba->curr = ln;
|
||||
return ln.key.group || ln.key.name;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ inifile_truncate
|
||||
*/
|
||||
static int inifile_truncate(inifile *dba, size_t size TSRMLS_DC)
|
||||
{
|
||||
int res;
|
||||
|
||||
if ((res=php_stream_truncate_set_size(dba->fp, size)) != 0) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error in ftruncate: %d", res);
|
||||
return FAILURE;
|
||||
}
|
||||
php_stream_seek(dba->fp, size, SEEK_SET);
|
||||
return SUCCESS;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ inifile_find_group
|
||||
* if found pos_grp_start points to "[group_name]"
|
||||
*/
|
||||
static int inifile_find_group(inifile *dba, const key_type *key, size_t *pos_grp_start TSRMLS_DC)
|
||||
{
|
||||
int ret = FAILURE;
|
||||
|
||||
php_stream_flush(dba->fp);
|
||||
php_stream_seek(dba->fp, 0, SEEK_SET);
|
||||
inifile_line_free(&dba->curr);
|
||||
inifile_line_free(&dba->next);
|
||||
|
||||
if (key->group && strlen(key->group)) {
|
||||
int res;
|
||||
line_type ln = {{NULL,NULL},{NULL}};
|
||||
|
||||
res = 1;
|
||||
while(inifile_read(dba, &ln TSRMLS_CC)) {
|
||||
if ((res=inifile_key_cmp(&ln.key, key TSRMLS_CC)) < 2) {
|
||||
ret = SUCCESS;
|
||||
break;
|
||||
}
|
||||
*pos_grp_start = php_stream_tell(dba->fp);
|
||||
}
|
||||
inifile_line_free(&ln);
|
||||
} else {
|
||||
*pos_grp_start = 0;
|
||||
ret = SUCCESS;
|
||||
}
|
||||
if (ret == FAILURE) {
|
||||
*pos_grp_start = php_stream_tell(dba->fp);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ inifile_next_group
|
||||
* only valid after a call to inifile_find_group
|
||||
* if any next group is found pos_grp_start points to "[group_name]" or whitespace before that
|
||||
*/
|
||||
static int inifile_next_group(inifile *dba, const key_type *key, size_t *pos_grp_start TSRMLS_DC)
|
||||
{
|
||||
int ret = FAILURE;
|
||||
line_type ln = {{NULL,NULL},{NULL}};
|
||||
|
||||
*pos_grp_start = php_stream_tell(dba->fp);
|
||||
ln.key.group = estrdup(key->group);
|
||||
while(inifile_read(dba, &ln TSRMLS_CC)) {
|
||||
if (inifile_key_cmp(&ln.key, key TSRMLS_CC) == 2) {
|
||||
ret = SUCCESS;
|
||||
break;
|
||||
}
|
||||
*pos_grp_start = php_stream_tell(dba->fp);
|
||||
}
|
||||
inifile_line_free(&ln);
|
||||
return ret;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ inifile_copy_to
|
||||
*/
|
||||
static int inifile_copy_to(inifile *dba, size_t pos_start, size_t pos_end, inifile **ini_copy TSRMLS_DC)
|
||||
{
|
||||
php_stream *fp;
|
||||
|
||||
if (pos_start == pos_end) {
|
||||
*ini_copy = NULL;
|
||||
return SUCCESS;
|
||||
}
|
||||
if ((fp = php_stream_temp_create(0, 64 * 1024)) == NULL) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not create temporary stream");
|
||||
*ini_copy = NULL;
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
if ((*ini_copy = inifile_alloc(fp, 1, 0 TSRMLS_CC)) == NULL) {
|
||||
/* writes error */
|
||||
return FAILURE;
|
||||
}
|
||||
php_stream_seek(dba->fp, pos_start, SEEK_SET);
|
||||
if (!php_stream_copy_to_stream(dba->fp, fp, pos_end - pos_start)) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not copy group [%d - %d] to temporary stream", pos_start, pos_end);
|
||||
return FAILURE;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ inifile_filter
|
||||
* copy from to dba while ignoring key name (group must equal)
|
||||
*/
|
||||
static int inifile_filter(inifile *dba, inifile *from, const key_type *key TSRMLS_DC)
|
||||
{
|
||||
size_t pos_start = 0, pos_next = 0, pos_curr;
|
||||
int ret = SUCCESS;
|
||||
line_type ln = {{NULL,NULL},{NULL}};
|
||||
|
||||
php_stream_seek(from->fp, 0, SEEK_SET);
|
||||
php_stream_seek(dba->fp, 0, SEEK_END);
|
||||
while(inifile_read(from, &ln TSRMLS_CC)) {
|
||||
switch(inifile_key_cmp(&ln.key, key TSRMLS_CC)) {
|
||||
case 0:
|
||||
pos_curr = php_stream_tell(from->fp);
|
||||
if (pos_start != pos_next) {
|
||||
php_stream_seek(from->fp, pos_start, SEEK_SET);
|
||||
if (!php_stream_copy_to_stream(from->fp, dba->fp, pos_next - pos_start)) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not copy [%d - %d] from temporary stream", pos_next, pos_start);
|
||||
ret = FAILURE;
|
||||
}
|
||||
php_stream_seek(from->fp, pos_curr, SEEK_SET);
|
||||
}
|
||||
pos_next = pos_start = pos_curr;
|
||||
break;
|
||||
case 1:
|
||||
pos_next = php_stream_tell(from->fp);
|
||||
break;
|
||||
case 2:
|
||||
/* the function is meant to process only entries from same group */
|
||||
assert(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (pos_start != pos_next) {
|
||||
php_stream_seek(from->fp, pos_start, SEEK_SET);
|
||||
if (!php_stream_copy_to_stream(from->fp, dba->fp, pos_next - pos_start)) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not copy [%d - %d] from temporary stream", pos_next, pos_start);
|
||||
ret = FAILURE;
|
||||
}
|
||||
}
|
||||
inifile_line_free(&ln);
|
||||
return SUCCESS;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ inifile_delete_replace_append
|
||||
*/
|
||||
static int inifile_delete_replace_append(inifile *dba, const key_type *key, const val_type *value, int append TSRMLS_DC)
|
||||
{
|
||||
size_t pos_grp_start, pos_grp_next;
|
||||
inifile *ini_tmp = NULL;
|
||||
php_stream *fp_tmp = NULL;
|
||||
int ret;
|
||||
|
||||
/* 1) Search group start
|
||||
* 2) Search next group
|
||||
* 3) If not append: Copy group to ini_tmp
|
||||
* 4) Open temp_stream and copy remainder
|
||||
* 5) Truncate stream
|
||||
* 6) If not append AND key.name given: Filtered copy back from ini_tmp
|
||||
* to stream. Otherwise the user wanted to delete the group.
|
||||
* 7) Append value if given
|
||||
* 8) Append temporary stream
|
||||
*/
|
||||
|
||||
assert(!append || (key->name && value)); /* missuse */
|
||||
|
||||
/* 1 - 3 */
|
||||
inifile_find_group(dba, key, &pos_grp_start TSRMLS_CC);
|
||||
inifile_next_group(dba, key, &pos_grp_next TSRMLS_CC);
|
||||
if (append) {
|
||||
ret = SUCCESS;
|
||||
} else {
|
||||
ret = inifile_copy_to(dba, pos_grp_start, pos_grp_next, &ini_tmp TSRMLS_CC);
|
||||
}
|
||||
|
||||
/* 4 */
|
||||
if (ret == SUCCESS) {
|
||||
fp_tmp = php_stream_temp_create(0, 64 * 1024);
|
||||
if (!fp_tmp) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not create temporary stream");
|
||||
ret = FAILURE;
|
||||
} else {
|
||||
php_stream_seek(dba->fp, 0, SEEK_END);
|
||||
if (pos_grp_next != php_stream_tell(dba->fp)) {
|
||||
php_stream_seek(dba->fp, pos_grp_next, SEEK_SET);
|
||||
if (!php_stream_copy_to_stream(dba->fp, fp_tmp, PHP_STREAM_COPY_ALL)) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not copy remainder to temporary stream");
|
||||
ret = FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 5 */
|
||||
if (ret == SUCCESS) {
|
||||
ret = inifile_truncate(dba, append ? pos_grp_next : pos_grp_start TSRMLS_CC); /* writes error on fail */
|
||||
}
|
||||
|
||||
if (ret == SUCCESS) {
|
||||
if (key->name && strlen(key->name)) {
|
||||
/* 6 */
|
||||
if (!append && ini_tmp) {
|
||||
ret = inifile_filter(dba, ini_tmp, key TSRMLS_CC);
|
||||
}
|
||||
|
||||
/* 7 */
|
||||
/* important: do not query ret==SUCCESS again: inifile_filter might fail but
|
||||
* however next operation must be done.
|
||||
*/
|
||||
if (value) {
|
||||
if (pos_grp_start == pos_grp_next && key->group && strlen(key->group)) {
|
||||
php_stream_printf(dba->fp TSRMLS_CC, "[%s]\n", key->group);
|
||||
}
|
||||
php_stream_printf(dba->fp TSRMLS_CC, "%s=%s\n", key->name, value->value ? value->value : "");
|
||||
}
|
||||
}
|
||||
|
||||
/* 8 */
|
||||
/* important: do not query ret==SUCCESS again: inifile_filter might fail but
|
||||
* however next operation must be done.
|
||||
*/
|
||||
if (fp_tmp && php_stream_tell(fp_tmp)) {
|
||||
php_stream_seek(fp_tmp, 0, SEEK_SET);
|
||||
php_stream_seek(dba->fp, 0, SEEK_END);
|
||||
if (!php_stream_copy_to_stream(fp_tmp, dba->fp, PHP_STREAM_COPY_ALL)) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Could not copy from temporary stream - ini file truncated");
|
||||
ret = FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ini_tmp) {
|
||||
php_stream_close(ini_tmp->fp);
|
||||
inifile_free(ini_tmp, 0);
|
||||
}
|
||||
if (fp_tmp) {
|
||||
php_stream_close(fp_tmp);
|
||||
}
|
||||
php_stream_flush(dba->fp);
|
||||
php_stream_seek(dba->fp, 0, SEEK_SET);
|
||||
|
||||
return ret;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ inifile_delete
|
||||
*/
|
||||
int inifile_delete(inifile *dba, const key_type *key TSRMLS_DC)
|
||||
{
|
||||
return inifile_delete_replace_append(dba, key, NULL, 0 TSRMLS_CC);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ inifile_relace
|
||||
*/
|
||||
int inifile_replace(inifile *dba, const key_type *key, const val_type *value TSRMLS_DC)
|
||||
{
|
||||
return inifile_delete_replace_append(dba, key, value, 0 TSRMLS_CC);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ inifile_append
|
||||
*/
|
||||
int inifile_append(inifile *dba, const key_type *key, const val_type *value TSRMLS_DC)
|
||||
{
|
||||
return inifile_delete_replace_append(dba, key, value, 1 TSRMLS_CC);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: sw=4 ts=4 fdm=marker
|
||||
* vim<600: sw=4 ts=4
|
||||
*/
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2003 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.02 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_02.txt. |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: Marcus Boerger <helly@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef PHP_LIB_INIFILE_H
|
||||
#define PHP_LIB_INIFILE_H
|
||||
|
||||
typedef struct {
|
||||
char *group;
|
||||
char *name;
|
||||
} key_type;
|
||||
|
||||
typedef struct {
|
||||
char *value;
|
||||
} val_type;
|
||||
|
||||
typedef struct {
|
||||
key_type key;
|
||||
val_type val;
|
||||
size_t pos;
|
||||
} line_type;
|
||||
|
||||
typedef struct {
|
||||
char *lockfn;
|
||||
int lockfd;
|
||||
php_stream *fp;
|
||||
int fd;
|
||||
int readonly;
|
||||
line_type curr;
|
||||
line_type next;
|
||||
} inifile;
|
||||
|
||||
val_type inifile_fetch(inifile *dba, const key_type *key, int skip TSRMLS_DC);
|
||||
int inifile_firstkey(inifile *dba TSRMLS_DC);
|
||||
int inifile_nextkey(inifile *dba TSRMLS_DC);
|
||||
int inifile_delete(inifile *dba, const key_type *key TSRMLS_DC);
|
||||
int inifile_replace(inifile *dba, const key_type *key, const val_type *val TSRMLS_DC);
|
||||
int inifile_append(inifile *dba, const key_type *key, const val_type *val TSRMLS_DC);
|
||||
char *inifile_version();
|
||||
|
||||
key_type inifile_key_split(const char *group_name);
|
||||
char * inifile_key_string(const key_type *key);
|
||||
|
||||
void inifile_key_free(key_type *key);
|
||||
void inifile_val_free(val_type *val);
|
||||
void inifile_line_free(line_type *ln);
|
||||
|
||||
inifile * inifile_alloc(php_stream *fp, int readonly, int persistent TSRMLS_DC);
|
||||
void inifile_free(inifile *dba, int persistent);
|
||||
|
||||
#endif
|
||||
@@ -1,12 +0,0 @@
|
||||
#ifndef PHP_INIFILE_H
|
||||
#define PHP_INIFILE_H
|
||||
|
||||
#if DBA_INIFILE
|
||||
|
||||
#include "php_dba.h"
|
||||
|
||||
DBA_FUNCS(inifile);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,29 +0,0 @@
|
||||
--TEST--
|
||||
DBA INIFILE handler test
|
||||
--SKIPIF--
|
||||
<?php
|
||||
$handler = 'inifile';
|
||||
require_once('skipif.inc');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$handler = 'inifile';
|
||||
require_once('test.inc');
|
||||
require_once('dba_handler.inc');
|
||||
?>
|
||||
--EXPECT--
|
||||
database handler: inifile
|
||||
3NYNYY
|
||||
Content String 2
|
||||
Content 2 replaced
|
||||
Read during write: not allowed
|
||||
Content 2 replaced 2nd time
|
||||
The 6th value
|
||||
array(3) {
|
||||
["key number 6"]=>
|
||||
string(13) "The 6th value"
|
||||
["key2"]=>
|
||||
string(27) "Content 2 replaced 2nd time"
|
||||
["key5"]=>
|
||||
string(23) "The last content string"
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
dnl
|
||||
dnl $Id$
|
||||
dnl config.m4 for extension mysqli
|
||||
|
||||
PHP_ARG_WITH(mysqli, for MySQLi support,
|
||||
[ --with-mysqli[=FILE] Include MySQLi support. FILE is the optional
|
||||
pathname to mysql_config.])
|
||||
|
||||
if test "$PHP_MYSQLI" != "no"; then
|
||||
|
||||
if test "$PHP_MYSQL" = "yes"; then
|
||||
AC_MSG_ERROR([--with-mysql (using bundled libs) can not be used together with --with-mysqli.])
|
||||
fi
|
||||
|
||||
if test "$PHP_MYSQLI" = "yes"; then
|
||||
MYSQL_CONFIG=`$php_shtool path mysql_config`
|
||||
else
|
||||
MYSQL_CONFIG=$PHP_MYSQLI
|
||||
fi
|
||||
|
||||
if test -x "$MYSQL_CONFIG" && $MYSQL_CONFIG --libs > /dev/null 2>&1; then
|
||||
MYSQLI_INCLINE=`$MYSQL_CONFIG --cflags | sed -e "s/'//g"`
|
||||
MYSQLI_LIBLINE=`$MYSQL_CONFIG --libs | sed -e "s/'//g"`
|
||||
else
|
||||
AC_MSG_RESULT([mysql_config not found])
|
||||
AC_MSG_ERROR([Please reinstall the mysql distribution])
|
||||
fi
|
||||
|
||||
dnl
|
||||
dnl Check the library
|
||||
dnl
|
||||
PHP_CHECK_LIBRARY(mysqlclient, mysql_bind_param,
|
||||
[
|
||||
PHP_EVAL_INCLINE($MYSQLI_INCLINE)
|
||||
PHP_EVAL_LIBLINE($MYSQLI_LIBLINE, MYSQLI_SHARED_LIBADD)
|
||||
AC_DEFINE(HAVE_MYSQLILIB,1,[ ])
|
||||
],[
|
||||
AC_MSG_ERROR([wrong mysql library version or lib not found. Check config.log for more information.])
|
||||
],[
|
||||
$MYSQLI_LIBLINE
|
||||
])
|
||||
|
||||
PHP_SUBST(MYSQLI_SHARED_LIBADD)
|
||||
PHP_NEW_EXTENSION(mysqli, mysqli.c mysqli_api.c mysqli_nonapi.c mysqli_fe.c mysqli_profiler.c mysqli_profiler_com.c, $ext_shared)
|
||||
fi
|
||||
@@ -1,451 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2003 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.02 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_02.txt. |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: Georg Richter <georg@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
#include "php.h"
|
||||
#include "php_ini.h"
|
||||
#include "ext/standard/info.h"
|
||||
#include "ext/standard/php_string.h"
|
||||
#include "php_mysqli.h"
|
||||
|
||||
#define MYSQLI_STORE_RESULT 0
|
||||
#define MYSQLI_USE_RESULT 1
|
||||
|
||||
ZEND_DECLARE_MODULE_GLOBALS(mysqli)
|
||||
static zend_object_handlers mysqli_object_handlers;
|
||||
PR_MAIN *prmain;
|
||||
|
||||
/* {{{ php_clear_stmt_bind */
|
||||
void php_clear_stmt_bind(STMT *stmt)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
if (stmt->stmt) {
|
||||
mysql_stmt_close(stmt->stmt);
|
||||
}
|
||||
|
||||
if (stmt->var_cnt) {
|
||||
for (i = 0; i < stmt->var_cnt; i++) {
|
||||
if (stmt->type == FETCH_RESULT) {
|
||||
if (stmt->bind[i].type == IS_STRING) {
|
||||
efree(stmt->bind[i].buffer);
|
||||
}
|
||||
}
|
||||
if (stmt->vars[i]) {
|
||||
ZVAL_DELREF(stmt->vars[i]);
|
||||
}
|
||||
}
|
||||
if (stmt->type == FETCH_RESULT) {
|
||||
efree(stmt->bind);
|
||||
}
|
||||
efree(stmt->vars);
|
||||
efree(stmt->is_null);
|
||||
}
|
||||
efree(stmt);
|
||||
return;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ mysqli_objects_dtor
|
||||
*/
|
||||
static void mysqli_objects_dtor(void *object, zend_object_handle handle TSRMLS_DC)
|
||||
{
|
||||
mysqli_object *intern = (mysqli_object *)object;
|
||||
MYSQLI_RESOURCE *my_res = (MYSQLI_RESOURCE *)intern->ptr;
|
||||
|
||||
/* link object */
|
||||
if (intern->zo.ce == mysqli_link_class_entry) {
|
||||
if (my_res && my_res->ptr) {
|
||||
mysql_close(my_res->ptr);
|
||||
}
|
||||
} else if (intern->zo.ce == mysqli_stmt_class_entry) { /* stmt object */
|
||||
if (my_res && my_res->ptr) {
|
||||
php_clear_stmt_bind((STMT *)my_res->ptr);
|
||||
}
|
||||
} else if (intern->zo.ce == mysqli_result_class_entry) { /* result object */
|
||||
if (my_res && my_res->ptr) {
|
||||
mysql_free_result(my_res->ptr);
|
||||
}
|
||||
}
|
||||
my_efree(my_res);
|
||||
zend_objects_destroy_object(object, handle TSRMLS_CC);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ mysqli_objects_clone
|
||||
*/
|
||||
static void mysqli_objects_clone(void *object, void **object_clone TSRMLS_DC)
|
||||
{
|
||||
/* TODO */
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ mysqli_objects_new
|
||||
*/
|
||||
PHP_MYSQLI_EXPORT(zend_object_value) mysqli_objects_new(zend_class_entry *class_type TSRMLS_DC)
|
||||
{
|
||||
zend_object_value retval;
|
||||
mysqli_object *intern;
|
||||
zval *tmp;
|
||||
|
||||
intern = emalloc(sizeof(mysqli_object));
|
||||
intern->zo.ce = class_type;
|
||||
intern->zo.in_get = 0;
|
||||
intern->zo.in_set = 0;
|
||||
intern->ptr = NULL;
|
||||
|
||||
ALLOC_HASHTABLE(intern->zo.properties);
|
||||
zend_hash_init(intern->zo.properties, 0, NULL, ZVAL_PTR_DTOR, 0);
|
||||
zend_hash_copy(intern->zo.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
|
||||
|
||||
retval.handle = zend_objects_store_put(intern, mysqli_objects_dtor, mysqli_objects_clone TSRMLS_CC);
|
||||
retval.handlers = &mysqli_object_handlers;
|
||||
|
||||
return retval;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ mysqli_module_entry
|
||||
*/
|
||||
zend_module_entry mysqli_module_entry = {
|
||||
#if ZEND_MODULE_API_NO >= 20010901
|
||||
STANDARD_MODULE_HEADER,
|
||||
#endif
|
||||
"mysqli",
|
||||
mysqli_functions,
|
||||
PHP_MINIT(mysqli),
|
||||
PHP_MSHUTDOWN(mysqli),
|
||||
PHP_RINIT(mysqli), /* Replace with NULL if there's nothing to do at request start */
|
||||
PHP_RSHUTDOWN(mysqli), /* Replace with NULL if there's nothing to do at request end */
|
||||
PHP_MINFO(mysqli),
|
||||
#if ZEND_MODULE_API_NO >= 20010901
|
||||
"0.1", /* Replace with version number for your extension */
|
||||
#endif
|
||||
STANDARD_MODULE_PROPERTIES
|
||||
};
|
||||
/* }}} */
|
||||
|
||||
#ifdef COMPILE_DL_MYSQLI
|
||||
ZEND_GET_MODULE(mysqli)
|
||||
#endif
|
||||
|
||||
/* {{{ PHP_INI_BEGIN
|
||||
*/
|
||||
PHP_INI_BEGIN()
|
||||
STD_PHP_INI_ENTRY_EX("mysqli.max_links", "-1", PHP_INI_SYSTEM, OnUpdateLong, max_links, zend_mysqli_globals, mysqli_globals, display_link_numbers)
|
||||
STD_PHP_INI_ENTRY("mysqli.default_host", NULL, PHP_INI_ALL, OnUpdateString, default_host, zend_mysqli_globals, mysqli_globals)
|
||||
STD_PHP_INI_ENTRY("mysqli.default_user", NULL, PHP_INI_ALL, OnUpdateString, default_user, zend_mysqli_globals, mysqli_globals)
|
||||
STD_PHP_INI_ENTRY("mysqli.default_pw", NULL, PHP_INI_ALL, OnUpdateString, default_pw, zend_mysqli_globals, mysqli_globals)
|
||||
STD_PHP_INI_ENTRY("mysqli.default_port", "3306", PHP_INI_ALL, OnUpdateLong, default_port, zend_mysqli_globals, mysqli_globals)
|
||||
STD_PHP_INI_ENTRY("mysqli.default_socket", NULL, PHP_INI_ALL, OnUpdateStringUnempty, default_socket, zend_mysqli_globals, mysqli_globals)
|
||||
PHP_INI_END()
|
||||
|
||||
/* }}} */
|
||||
|
||||
/* {{{ php_mysqli_init_globals
|
||||
*/
|
||||
static void php_mysqli_init_globals(zend_mysqli_globals *mysqli_globals)
|
||||
{
|
||||
mysqli_globals->num_links = 0;
|
||||
mysqli_globals->max_links = 0;
|
||||
mysqli_globals->default_port = 0;
|
||||
mysqli_globals->default_host = NULL;
|
||||
mysqli_globals->default_user = NULL;
|
||||
mysqli_globals->default_pw = NULL;
|
||||
mysqli_globals->default_socket = NULL;
|
||||
mysqli_globals->profiler = 0;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ PHP_MINIT_FUNCTION
|
||||
*/
|
||||
PHP_MINIT_FUNCTION(mysqli)
|
||||
{
|
||||
|
||||
ZEND_INIT_MODULE_GLOBALS(mysqli, php_mysqli_init_globals, NULL);
|
||||
REGISTER_INI_ENTRIES();
|
||||
|
||||
memcpy(&mysqli_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
|
||||
mysqli_object_handlers.clone_obj = zend_objects_store_clone_obj;
|
||||
|
||||
REGISTER_MYSQLI_CLASS_ENTRY("mysqli", mysqli_link_class_entry, mysqli_link_methods);
|
||||
REGISTER_MYSQLI_CLASS_ENTRY("mysqli_result", mysqli_result_class_entry, mysqli_result_methods);
|
||||
REGISTER_MYSQLI_CLASS_ENTRY("mysqli_stmt", mysqli_stmt_class_entry, mysqli_stmt_methods);
|
||||
|
||||
/* mysqli_options */
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_READ_DEFAULT_GROUP", MYSQL_READ_DEFAULT_GROUP, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_READ_DEFAULT_FILE", MYSQL_READ_DEFAULT_FILE, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_OPT_CONNECT_TIMEOUT", MYSQL_OPT_CONNECT_TIMEOUT, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_OPT_LOCAL_INFILE", MYSQL_OPT_LOCAL_INFILE, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_INIT_COMMAND", MYSQL_INIT_COMMAND, CONST_CS | CONST_PERSISTENT);
|
||||
|
||||
/* mysqli_real_connect flags */
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_CLIENT_SSL", CLIENT_SSL, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_CLIENT_COMPRESS",CLIENT_COMPRESS, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_CLIENT_INTERACTIVE", CLIENT_INTERACTIVE, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_CLIENT_IGNORE_SPACE", CLIENT_IGNORE_SPACE, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_CLIENT_NO_SCHEMA", CLIENT_NO_SCHEMA, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_CLIENT_MULTI_QUERIES", CLIENT_MULTI_QUERIES, CONST_CS | CONST_PERSISTENT);
|
||||
|
||||
|
||||
/* for mysqli_query */
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_STORE_RESULT", 0, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_USE_RESULT", 1, CONST_CS | CONST_PERSISTENT);
|
||||
|
||||
/* for mysqli_fetch_assoc */
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_ASSOC", MYSQLI_ASSOC, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_NUM", MYSQLI_NUM, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_BOTH", MYSQLI_BOTH, CONST_CS | CONST_PERSISTENT);
|
||||
|
||||
|
||||
/* column information */
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_NOT_NULL_FLAG", NOT_NULL_FLAG, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_PRI_KEY_FLAG", PRI_KEY_FLAG, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_UNIQUE_KEY_FLAG", UNIQUE_KEY_FLAG, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_MULTIPLE_KEY_FLAG", MULTIPLE_KEY_FLAG, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_BLOB_FLAG", BLOB_FLAG, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_UNSIGNED_FLAG", UNSIGNED_FLAG, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_ZEROFILL_FLAG", ZEROFILL_FLAG, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_AUTO_INCREMENT_FLAG", AUTO_INCREMENT_FLAG, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_TIMESTAMP_FLAG", TIMESTAMP_FLAG, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_SET_FLAG", SET_FLAG, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_NUM_FLAG", NUM_FLAG, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_PART_KEY_FLAG", PART_KEY_FLAG, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_GROUP_FLAG", GROUP_FLAG, CONST_CS | CONST_PERSISTENT);
|
||||
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_DECIMAL", FIELD_TYPE_DECIMAL, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_TINY", FIELD_TYPE_TINY, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_SHORT", FIELD_TYPE_SHORT, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_LONG", FIELD_TYPE_LONG, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_FLOAD", FIELD_TYPE_FLOAT, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_DOUBLE", FIELD_TYPE_DOUBLE, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_NULL", FIELD_TYPE_NULL, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_TIMESTAMP", FIELD_TYPE_TIMESTAMP, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_LONGLONG", FIELD_TYPE_LONGLONG, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_INT24", FIELD_TYPE_INT24, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_DATE", FIELD_TYPE_DATE, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_TIME", FIELD_TYPE_TIME, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_DATETIME", FIELD_TYPE_DATETIME , CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_YEAR", FIELD_TYPE_YEAR, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_NEWDATE", FIELD_TYPE_NEWDATE, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_ENUM", FIELD_TYPE_ENUM, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_SET", FIELD_TYPE_SET, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_TINY_BLOB", FIELD_TYPE_TINY_BLOB, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_MEDIUM_BLOB", FIELD_TYPE_MEDIUM_BLOB, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_LONG_BLOB", FIELD_TYPE_LONG_BLOB, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_BLOB", FIELD_TYPE_BLOB, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_VAR_STRING", FIELD_TYPE_VAR_STRING, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_STRING", FIELD_TYPE_STRING, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_CHAR", FIELD_TYPE_CHAR, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_INTERVAL", FIELD_TYPE_INTERVAL, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_TYPE_GEOMETRY", FIELD_TYPE_GEOMETRY, CONST_CS | CONST_PERSISTENT);
|
||||
|
||||
/* bindtypes for mysqli_bind_result */
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_BIND_STRING", MYSQLI_BIND_STRING, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_BIND_INT", MYSQLI_BIND_INT, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_BIND_DOUBLE", MYSQLI_BIND_DOUBLE, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_BIND_SEND_DATA", MYSQLI_BIND_SEND_DATA, CONST_CS | CONST_PERSISTENT);
|
||||
|
||||
/* replication */
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_RPL_MASTER", MYSQL_RPL_MASTER, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_RPL_SLAVE", MYSQL_RPL_SLAVE, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_RPL_ADMIN", MYSQL_RPL_ADMIN, CONST_CS | CONST_PERSISTENT);
|
||||
|
||||
/* bind blob support */
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_NEED_DATA", MYSQL_NEED_DATA, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_NO_DATA", MYSQL_NO_DATA, CONST_CS | CONST_PERSISTENT);
|
||||
|
||||
/* profiler support */
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_PR_REPORT_STDERR", 1, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_PR_REPORT_PORT", 2, CONST_CS | CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_PR_REPORT_FILE", 3, CONST_CS | CONST_PERSISTENT);
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ PHP_MSHUTDOWN_FUNCTION
|
||||
*/
|
||||
PHP_MSHUTDOWN_FUNCTION(mysqli)
|
||||
{
|
||||
/* uncomment this line if you have INI entries
|
||||
UNREGISTER_INI_ENTRIES();
|
||||
*/
|
||||
return SUCCESS;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* Remove if there's nothing to do at request start */
|
||||
/* {{{ PHP_RINIT_FUNCTION
|
||||
*/
|
||||
PHP_RINIT_FUNCTION(mysqli)
|
||||
{
|
||||
MyG(error_msg) = NULL;
|
||||
MyG(error_no) = 0;
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* Remove if there's nothing to do at request end */
|
||||
/* {{{ PHP_RSHUTDOWN_FUNCTION
|
||||
*/
|
||||
PHP_RSHUTDOWN_FUNCTION(mysqli)
|
||||
{
|
||||
if (MyG(error_msg)) {
|
||||
efree(MyG(error_msg));
|
||||
}
|
||||
|
||||
if (MyG(profiler)) {
|
||||
if (prmain->header.child) {
|
||||
php_mysqli_profiler_report((PR_COMMON *)prmain, 0);
|
||||
}
|
||||
switch (prmain->mode) {
|
||||
case MYSQLI_PR_REPORT_FILE:
|
||||
fclose(prmain->fp);
|
||||
efree(prmain->name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ PHP_MINFO_FUNCTION
|
||||
*/
|
||||
PHP_MINFO_FUNCTION(mysqli)
|
||||
{
|
||||
php_info_print_table_start();
|
||||
php_info_print_table_header(2, "MysqlI Support", "enabled");
|
||||
php_info_print_table_row(2, "Client API version", mysql_get_client_info());
|
||||
php_info_print_table_row(2, "MYSQLI_SOCKET", MYSQL_UNIX_ADDR);
|
||||
|
||||
|
||||
php_info_print_table_end();
|
||||
|
||||
DISPLAY_INI_ENTRIES();
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ php_mysqli_fetch_into_hash
|
||||
*/
|
||||
void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags)
|
||||
{
|
||||
MYSQL_RES *result;
|
||||
zval *mysql_result;
|
||||
int fetchtype;
|
||||
int copyflag;
|
||||
unsigned int i;
|
||||
MYSQL_FIELD *fields;
|
||||
MYSQL_ROW row;
|
||||
unsigned long *field_len;
|
||||
PR_RESULT *prresult;
|
||||
PR_COMMAND *prcommand;
|
||||
|
||||
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|l", &mysql_result, mysqli_result_class_entry, &fetchtype) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ZEND_NUM_ARGS() < 2 && !override_flags) {
|
||||
fetchtype = MYSQLI_BOTH;
|
||||
}
|
||||
|
||||
if (override_flags) {
|
||||
fetchtype = override_flags;
|
||||
}
|
||||
|
||||
MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, prresult, PR_RESULT *, &mysql_result, "mysqli_result");
|
||||
|
||||
MYSQLI_PROFILER_COMMAND_START(prcommand, prresult);
|
||||
|
||||
fields = mysql_fetch_fields(result);
|
||||
if (!(row = mysql_fetch_row(result))) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
array_init(return_value);
|
||||
field_len = mysql_fetch_lengths(result);
|
||||
|
||||
for (i = 0; i < mysql_num_fields(result); i++) {
|
||||
if (row[i]) {
|
||||
char *column;
|
||||
int column_len;
|
||||
|
||||
/* check if we need magic quotes */
|
||||
if (PG(magic_quotes_runtime)) {
|
||||
column = php_addslashes(row[i], field_len[i], &column_len, 0 TSRMLS_CC);
|
||||
copyflag = 0;
|
||||
} else {
|
||||
column = row[i];
|
||||
column_len = field_len[i];
|
||||
copyflag = 1;
|
||||
}
|
||||
if (fetchtype & MYSQLI_NUM) {
|
||||
add_index_stringl(return_value, i, column, column_len, copyflag);
|
||||
copyflag = 1;
|
||||
}
|
||||
if (fetchtype & MYSQLI_ASSOC) {
|
||||
add_assoc_stringl(return_value, fields[i].name, column, column_len, copyflag);
|
||||
}
|
||||
} else {
|
||||
if (fetchtype & MYSQLI_NUM) {
|
||||
add_index_null(return_value, i);
|
||||
}
|
||||
if (fetchtype & MYSQLI_ASSOC) {
|
||||
add_assoc_null(return_value, fields[i].name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (MyG(profiler)) {
|
||||
char tmp[10];
|
||||
sprintf ((char *)&tmp,"row[%d]", mysql_num_fields(result));
|
||||
MYSQLI_PROFILER_COMMAND_RETURNSTRING(prcommand, tmp);
|
||||
prresult->fetched_rows++;
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ php_mysqli_set_error
|
||||
*/
|
||||
PHP_MYSQLI_API void php_mysqli_set_error(long mysql_errno, char *mysql_err TSRMLS_DC)
|
||||
{
|
||||
MyG(error_no) = mysql_errno;
|
||||
if (MyG(error_msg)) {
|
||||
efree(MyG(error_msg));
|
||||
}
|
||||
MyG(error_msg) = estrdup(mysql_err);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: noet sw=4 ts=4 fdm=marker
|
||||
* vim<600: noet sw=4 ts=4
|
||||
*/
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,235 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 4 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2002 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.02 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_02.txt. |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: Georg Richter <georg@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
#include "php.h"
|
||||
#include "php_ini.h"
|
||||
#include "ext/standard/info.h"
|
||||
#include "php_mysqli.h"
|
||||
|
||||
|
||||
/* {{{ mysqli_functions[]
|
||||
*
|
||||
* Every user visible function must have an entry in mysqli_functions[].
|
||||
*/
|
||||
function_entry mysqli_functions[] = {
|
||||
PHP_FE(mysqli_affected_rows, NULL)
|
||||
PHP_FE(mysqli_autocommit, NULL)
|
||||
PHP_FE(mysqli_bind_param, NULL)
|
||||
PHP_FE(mysqli_bind_result, NULL)
|
||||
PHP_FE(mysqli_change_user, NULL)
|
||||
PHP_FE(mysqli_character_set_name, NULL)
|
||||
PHP_FALIAS(mysqli_client_encoding,
|
||||
mysqli_character_set_name, NULL)
|
||||
PHP_FE(mysqli_close, NULL)
|
||||
PHP_FE(mysqli_commit, NULL)
|
||||
PHP_FE(mysqli_connect, NULL)
|
||||
PHP_FE(mysqli_data_seek, NULL)
|
||||
PHP_FE(mysqli_debug, NULL)
|
||||
PHP_FE(mysqli_disable_reads_from_master, NULL)
|
||||
PHP_FE(mysqli_disable_rpl_parse, NULL)
|
||||
PHP_FE(mysqli_dump_debug_info, NULL)
|
||||
PHP_FE(mysqli_enable_reads_from_master, NULL)
|
||||
PHP_FE(mysqli_enable_rpl_parse, NULL)
|
||||
PHP_FE(mysqli_errno, NULL)
|
||||
PHP_FE(mysqli_error, NULL)
|
||||
PHP_FE(mysqli_execute, NULL)
|
||||
PHP_FE(mysqli_fetch, NULL)
|
||||
PHP_FE(mysqli_fetch_field, NULL)
|
||||
PHP_FE(mysqli_fetch_fields, NULL)
|
||||
PHP_FE(mysqli_fetch_field_direct, NULL)
|
||||
PHP_FE(mysqli_fetch_lengths, NULL)
|
||||
PHP_FE(mysqli_fetch_array, NULL)
|
||||
PHP_FE(mysqli_fetch_assoc, NULL)
|
||||
PHP_FE(mysqli_fetch_object, NULL)
|
||||
PHP_FE(mysqli_fetch_row, NULL)
|
||||
PHP_FE(mysqli_field_count, NULL)
|
||||
PHP_FE(mysqli_field_seek, NULL)
|
||||
PHP_FE(mysqli_field_tell, NULL)
|
||||
PHP_FE(mysqli_free_result, NULL)
|
||||
PHP_FE(mysqli_get_client_info, NULL)
|
||||
PHP_FE(mysqli_get_host_info, NULL)
|
||||
PHP_FE(mysqli_get_proto_info, NULL)
|
||||
PHP_FE(mysqli_get_server_info, NULL)
|
||||
PHP_FE(mysqli_get_server_version, NULL)
|
||||
PHP_FE(mysqli_init, NULL)
|
||||
PHP_FE(mysqli_info, NULL)
|
||||
PHP_FE(mysqli_insert_id, NULL)
|
||||
PHP_FE(mysqli_kill, NULL)
|
||||
PHP_FE(mysqli_master_query, NULL)
|
||||
PHP_FE(mysqli_num_fields, NULL)
|
||||
PHP_FE(mysqli_num_rows, NULL)
|
||||
PHP_FE(mysqli_options, NULL)
|
||||
PHP_FE(mysqli_param_count, NULL)
|
||||
PHP_FE(mysqli_ping, NULL)
|
||||
PHP_FE(mysqli_prepare, NULL)
|
||||
PHP_FE(mysqli_prepare_result, NULL)
|
||||
PHP_FE(mysqli_profiler, NULL)
|
||||
PHP_FE(mysqli_query, NULL)
|
||||
PHP_FE(mysqli_read_query_result, NULL)
|
||||
PHP_FE(mysqli_real_connect, NULL)
|
||||
PHP_FE(mysqli_real_escape_string, NULL)
|
||||
PHP_FALIAS(mysqli_escape_string,
|
||||
mysqli_real_escape_string, NULL)
|
||||
PHP_FE(mysqli_real_query, NULL)
|
||||
PHP_FE(mysqli_reload, NULL)
|
||||
PHP_FE(mysqli_rollback, NULL)
|
||||
PHP_FE(mysqli_rpl_parse_enabled, NULL)
|
||||
PHP_FE(mysqli_rpl_probe, NULL)
|
||||
PHP_FE(mysqli_rpl_query_type, NULL)
|
||||
PHP_FE(mysqli_select_db, NULL)
|
||||
PHP_FE(mysqli_send_long_data, NULL)
|
||||
PHP_FE(mysqli_send_query, NULL)
|
||||
PHP_FALIAS(mysqli_set_opt, mysqli_options, NULL)
|
||||
PHP_FE(mysqli_slave_query, NULL)
|
||||
PHP_FE(mysqli_ssl_set, NULL)
|
||||
PHP_FE(mysqli_stat, NULL)
|
||||
PHP_FE(mysqli_stmt_affected_rows, NULL)
|
||||
PHP_FE(mysqli_stmt_close, NULL)
|
||||
PHP_FE(mysqli_stmt_errno, NULL)
|
||||
PHP_FE(mysqli_stmt_error, NULL)
|
||||
PHP_FE(mysqli_store_result, NULL)
|
||||
PHP_FE(mysqli_stmt_store_result, NULL)
|
||||
PHP_FE(mysqli_thread_id, NULL)
|
||||
PHP_FE(mysqli_thread_safe, NULL)
|
||||
PHP_FE(mysqli_use_result, NULL)
|
||||
PHP_FE(mysqli_warning_count, NULL)
|
||||
{NULL, NULL, NULL} /* Must be the last line in mysqli_functions[] */
|
||||
};
|
||||
/* }}} */
|
||||
|
||||
/* {{{ mysqli_link_methods[]
|
||||
*
|
||||
* Every user visible function must have an entry in mysqli_functions[].
|
||||
*/
|
||||
function_entry mysqli_link_methods[] = {
|
||||
PHP_FALIAS(affected_rows,mysqli_affected_rows,NULL)
|
||||
PHP_FALIAS(autocommit,mysqli_autocommit,NULL)
|
||||
PHP_FALIAS(change_user,mysqli_change_user,NULL)
|
||||
PHP_FALIAS(character_set_name,mysqli_character_set_name,NULL)
|
||||
PHP_FALIAS(client_encoding, mysqli_character_set_name,NULL)
|
||||
PHP_FALIAS(close,mysqli_close,NULL)
|
||||
PHP_FALIAS(commit,mysqli_commit,NULL)
|
||||
PHP_FALIAS(connect,mysqli_connect,NULL)
|
||||
PHP_FALIAS(debug,mysqli_debug,NULL)
|
||||
PHP_FALIAS(disable_reads_from_master,mysqli_disable_reads_from_master,NULL)
|
||||
PHP_FALIAS(disable_rpl_parse,mysqli_disable_rpl_parse,NULL)
|
||||
PHP_FALIAS(dump_debug_info,mysqli_dump_debug_info,NULL)
|
||||
PHP_FALIAS(enable_reads_from_master,mysqli_enable_reads_from_master,NULL)
|
||||
PHP_FALIAS(enable_rpl_parse,mysqli_enable_rpl_parse,NULL)
|
||||
PHP_FALIAS(errno,mysqli_errno,NULL)
|
||||
PHP_FALIAS(error,mysqli_error,NULL)
|
||||
PHP_FALIAS(get_client_info,mysqli_get_client_info,NULL)
|
||||
PHP_FALIAS(get_host_info,mysqli_get_host_info,NULL)
|
||||
PHP_FALIAS(get_proto_info,mysqli_get_proto_info,NULL)
|
||||
PHP_FALIAS(get_server_info,mysqli_get_server_info,NULL)
|
||||
PHP_FALIAS(get_server_version,mysqli_get_server_version,NULL)
|
||||
PHP_FALIAS(init,mysqli_init,NULL)
|
||||
PHP_FALIAS(info,mysqli_info,NULL)
|
||||
PHP_FALIAS(insert_id,mysqli_insert_id,NULL)
|
||||
PHP_FALIAS(kill,mysqli_kill,NULL)
|
||||
PHP_FALIAS(master_query,mysqli_master_query,NULL)
|
||||
PHP_FALIAS(options,mysqli_options,NULL)
|
||||
PHP_FALIAS(ping,mysqli_ping,NULL)
|
||||
PHP_FALIAS(prepare,mysqli_prepare,NULL)
|
||||
PHP_FALIAS(query,mysqli_query,NULL)
|
||||
PHP_FALIAS(read_query_result,mysqli_read_query_result,NULL)
|
||||
PHP_FALIAS(real_connect,mysqli_real_connect,NULL)
|
||||
PHP_FALIAS(real_escape_string,mysqli_real_escape_string,NULL)
|
||||
PHP_FALIAS(escape_string, mysqli_real_escape_string,NULL)
|
||||
PHP_FALIAS(real_query,mysqli_real_query,NULL)
|
||||
PHP_FALIAS(reload,mysqli_reload,NULL)
|
||||
PHP_FALIAS(rollback,mysqli_rollback,NULL)
|
||||
PHP_FALIAS(rpl_parse_enabled,mysqli_rpl_parse_enabled,NULL)
|
||||
PHP_FALIAS(rpl_probe,mysqli_rpl_probe,NULL)
|
||||
PHP_FALIAS(rpl_query_type,mysqli_rpl_query_type,NULL)
|
||||
PHP_FALIAS(select_db,mysqli_select_db,NULL)
|
||||
PHP_FALIAS(set_opt, mysqli_options,NULL)
|
||||
PHP_FALIAS(slave_query,mysqli_slave_query,NULL)
|
||||
PHP_FALIAS(ssl_set,mysqli_ssl_set,NULL)
|
||||
PHP_FALIAS(stat,mysqli_stat,NULL)
|
||||
PHP_FALIAS(store_result,mysqli_store_result,NULL)
|
||||
PHP_FALIAS(thread_id, mysqli_thread_id,NULL)
|
||||
PHP_FALIAS(thread_safe,mysqli_thread_safe,NULL)
|
||||
PHP_FALIAS(use_result,mysqli_use_result,NULL)
|
||||
PHP_FALIAS(warning_count,mysqli_warning_count,NULL)
|
||||
{NULL, NULL, NULL}
|
||||
};
|
||||
/* }}} */
|
||||
|
||||
/* {{{ mysqli_result_methods[]
|
||||
*
|
||||
* Every user visible function must have an entry in mysqli_result_functions[].
|
||||
*/
|
||||
function_entry mysqli_result_methods[] = {
|
||||
PHP_FALIAS(close,mysqli_free_result,NULL)
|
||||
PHP_FALIAS(free,mysqli_free_result,NULL)
|
||||
PHP_FALIAS(data_seek,mysqli_data_seek,NULL)
|
||||
PHP_FALIAS(fetch_field,mysqli_fetch_field,NULL)
|
||||
PHP_FALIAS(fetch_fields,mysqli_fetch_fields,NULL)
|
||||
PHP_FALIAS(fetvh_field_direct,mysqli_fetch_field_direct,NULL)
|
||||
PHP_FALIAS(fetch_lengths,mysqli_fetch_lengths,NULL)
|
||||
PHP_FALIAS(fetch_array,mysqli_fetch_array,NULL)
|
||||
PHP_FALIAS(fetch_assoc,mysqli_fetch_assoc,NULL)
|
||||
PHP_FALIAS(fetch_object,mysqli_fetch_object,NULL)
|
||||
PHP_FALIAS(fetch_row,mysqli_fetch_row,NULL)
|
||||
PHP_FALIAS(field_count,mysqli_field_count,NULL)
|
||||
PHP_FALIAS(field_seek,mysqli_field_seek,NULL)
|
||||
PHP_FALIAS(field_tell,mysqli_field_tell,NULL)
|
||||
PHP_FALIAS(free_result,mysqli_free_result,NULL)
|
||||
PHP_FALIAS(num_fields,mysqli_num_fields,NULL)
|
||||
PHP_FALIAS(num_rows,mysqli_num_rows,NULL)
|
||||
{NULL, NULL, NULL}
|
||||
};
|
||||
/* }}} */
|
||||
|
||||
/* {{{ mysqli_stmt_methods[]
|
||||
*
|
||||
* Every user visible function must have an entry in mysqli_stmt_functions[].
|
||||
*/
|
||||
function_entry mysqli_stmt_methods[] = {
|
||||
PHP_FALIAS(affected_rows,mysqli_stmt_affected_rows,NULL)
|
||||
PHP_FALIAS(bind_param,mysqli_bind_param,NULL)
|
||||
PHP_FALIAS(bind_result,mysqli_bind_result,NULL)
|
||||
PHP_FALIAS(execute,mysqli_execute,NULL)
|
||||
PHP_FALIAS(fetch,mysqli_fetch,NULL)
|
||||
PHP_FALIAS(param_count,mysqli_param_count,NULL)
|
||||
PHP_FALIAS(send_long_data,mysqli_send_long_data,NULL)
|
||||
PHP_FALIAS(store_result,mysqli_stmt_store_result,NULL)
|
||||
PHP_FALIAS(close,mysqli_stmt_close,NULL)
|
||||
PHP_FALIAS(errno,mysqli_stmt_errno,NULL)
|
||||
PHP_FALIAS(error,mysqli_stmt_error,NULL)
|
||||
{NULL, NULL, NULL}
|
||||
};
|
||||
/* }}} */
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: noet sw=4 ts=4 fdm=marker
|
||||
* vim<600: noet sw=4 ts=4
|
||||
*/
|
||||
@@ -1,207 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2003 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.02 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_02.txt. |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: Georg Richter <georg@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
#include "php.h"
|
||||
#include "php_ini.h"
|
||||
#include "ext/standard/info.h"
|
||||
#include "php_mysqli.h"
|
||||
|
||||
/* {{{ proto resource mysqli_connect([string hostname [,string username [,string passwd [,string dbname [,int port [,string socket]]]]]])
|
||||
Open a connection to a mysql server */
|
||||
PHP_FUNCTION(mysqli_connect)
|
||||
{
|
||||
MYSQL *mysql;
|
||||
MYSQLI_RESOURCE *mysqli_resource;
|
||||
PR_MYSQL *prmysql = NULL;
|
||||
zval *object = getThis();
|
||||
char *hostname = NULL, *username=NULL, *passwd=NULL, *dbname=NULL, *socket=NULL;
|
||||
unsigned int hostname_len, username_len, passwd_len, dbname_len, socket_len;
|
||||
unsigned int port=0;
|
||||
struct timeval starttime;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ssssls", &hostname, &hostname_len, &username, &username_len,
|
||||
&passwd, &passwd_len, &dbname, &dbname_len, &port, &socket, &socket_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* TODO: safe mode handling */
|
||||
if (PG(sql_safe_mode)){
|
||||
} else {
|
||||
if (!passwd) {
|
||||
passwd = MyG(default_pw);
|
||||
if (!username){
|
||||
username = MyG(default_user);
|
||||
if (!hostname) {
|
||||
hostname = MyG(default_host);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
mysql = mysql_init(NULL);
|
||||
|
||||
if (MyG(profiler)){
|
||||
gettimeofday(&starttime, NULL);
|
||||
}
|
||||
|
||||
if (mysql_real_connect(mysql,hostname,username,passwd,dbname,port,socket,0) == NULL) {
|
||||
/* Save error messages */
|
||||
|
||||
php_mysqli_set_error(mysql_errno(mysql), (char *) mysql_error(mysql) TSRMLS_CC);
|
||||
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", mysql_error(mysql));
|
||||
/* free mysql structure */
|
||||
mysql_close(mysql);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (MyG(profiler)) {
|
||||
prmysql = (PR_MYSQL *)MYSQLI_PROFILER_NEW(prmain, MYSQLI_PR_MYSQL, 0);
|
||||
php_mysqli_profiler_timediff(starttime, &prmysql->header.elapsedtime);
|
||||
MYSQLI_PROFILER_STARTTIME(prmysql);
|
||||
prmysql->hostname = estrdup(hostname);
|
||||
prmysql->username = estrdup(username);
|
||||
prmysql->thread_id = mysql->thread_id;
|
||||
}
|
||||
|
||||
mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE));
|
||||
mysqli_resource->ptr = (void *)mysql;
|
||||
mysqli_resource->prinfo = prmysql;
|
||||
|
||||
|
||||
if (!object) {
|
||||
MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_link_class_entry);
|
||||
} else {
|
||||
((mysqli_object *) zend_object_store_get_object(object TSRMLS_CC))->ptr = mysqli_resource;
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto array mysqli_fetch_array (resource result [,int resulttype])
|
||||
Fetch a result row as an associative array, a numeric array, or both */
|
||||
PHP_FUNCTION(mysqli_fetch_array)
|
||||
{
|
||||
php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto array mysqli_fetch_assoc (resource result)
|
||||
Fetch a result row as an associative array */
|
||||
PHP_FUNCTION(mysqli_fetch_assoc)
|
||||
{
|
||||
php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, MYSQLI_ASSOC);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto array mysqli_fetch_object (resource result)
|
||||
Fetch a result row as an object */
|
||||
PHP_FUNCTION(mysqli_fetch_object)
|
||||
{
|
||||
php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, MYSQLI_ASSOC);
|
||||
|
||||
if (Z_TYPE_P(return_value) == IS_ARRAY) {
|
||||
object_and_properties_init(return_value, ZEND_STANDARD_CLASS_DEF_PTR, Z_ARRVAL_P(return_value));
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto resource mysqli_query(resource link, string query [,int resultmode])
|
||||
Send a MySQL query */
|
||||
PHP_FUNCTION(mysqli_query) {
|
||||
MYSQL *mysql;
|
||||
zval *mysql_link;
|
||||
MYSQLI_RESOURCE *mysqli_resource;
|
||||
MYSQL_RES *result;
|
||||
PR_MYSQL *prmysql;
|
||||
PR_QUERY *prquery;
|
||||
PR_RESULT *prresult;
|
||||
char *query = NULL;
|
||||
unsigned int query_len;
|
||||
unsigned int resultmode = 0;
|
||||
struct timeval starttime;
|
||||
|
||||
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|l", &mysql_link, mysqli_link_class_entry, &query, &query_len, &resultmode) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
MYSQLI_FETCH_RESOURCE(mysql, MYSQL*, prmysql, PR_MYSQL *, &mysql_link, "mysqli_link");
|
||||
|
||||
/* profiling information */
|
||||
if (MyG(profiler)) {
|
||||
prquery = (PR_QUERY *)MYSQLI_PROFILER_NEW(prmysql, MYSQLI_PR_QUERY, 1);
|
||||
prquery->explain.query = my_estrdup(query);
|
||||
if (!strncasecmp("select", query, 6)){
|
||||
if (!(MYSQLI_PROFILER_EXPLAIN(&prquery->explain, &prquery->header, mysql, query))) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mysql_real_query(mysql, query, query_len)) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (MyG(profiler)) {
|
||||
MYSQLI_PROFILER_ELAPSEDTIME(prquery);
|
||||
prquery->insertid = mysql_insert_id(mysql);
|
||||
prquery->affectedrows = mysql_affected_rows(mysql);
|
||||
}
|
||||
|
||||
if (!mysql_field_count(mysql)) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
/* profiler result information */
|
||||
if (MyG(profiler)) {
|
||||
gettimeofday(&starttime, NULL);
|
||||
prresult = (PR_RESULT *)MYSQLI_PROFILER_NEW(prquery, MYSQLI_PR_RESULT, 1);
|
||||
}
|
||||
|
||||
result = (resultmode == MYSQLI_USE_RESULT) ? mysql_use_result(mysql) : mysql_store_result(mysql);
|
||||
|
||||
if (result && MyG(profiler)) {
|
||||
MYSQLI_PROFILER_ELAPSEDTIME(prresult);
|
||||
prresult->rows = result->row_count;
|
||||
prresult->columns = result->field_count;
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE));
|
||||
mysqli_resource->ptr = (void *)result;
|
||||
mysqli_resource->prinfo = (void *)prresult;
|
||||
MYSQLI_RETURN_RESOURCE(mysqli_resource, mysqli_result_class_entry);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: noet sw=4 ts=4 fdm=marker
|
||||
* vim<600: noet sw=4 ts=4
|
||||
*/
|
||||
@@ -1,304 +0,0 @@
|
||||
/*
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2003 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.02 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available at through the world-wide-web at |
|
||||
| http://www.php.net/license/2_02.txt. |
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: Georg Richter <georg@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
|
||||
$Id$
|
||||
*/
|
||||
|
||||
/* A little hack to prevent build break, when mysql is used together with
|
||||
* c-client, which also defines LIST.
|
||||
*/
|
||||
#ifdef LIST
|
||||
#undef LIST
|
||||
#endif
|
||||
|
||||
#include <mysql.h>
|
||||
#include "mysqli_profiler.h"
|
||||
|
||||
#ifndef PHP_MYSQLI_H
|
||||
#define PHP_MYSQLI_H
|
||||
|
||||
|
||||
typedef struct {
|
||||
ulong buflen;
|
||||
char *buffer;
|
||||
ulong type;
|
||||
} BIND_BUFFER;
|
||||
|
||||
typedef struct {
|
||||
MYSQL_STMT *stmt;
|
||||
unsigned int var_cnt;
|
||||
zval **vars;
|
||||
BIND_BUFFER *bind;
|
||||
char *is_null;
|
||||
char type;
|
||||
} STMT;
|
||||
|
||||
typedef struct {
|
||||
void *prinfo; /* profiler info */
|
||||
void *ptr; /* resource: (mysql, result, stmt) */
|
||||
} MYSQLI_RESOURCE;
|
||||
|
||||
typedef struct _mysqli_object {
|
||||
zend_object zo;
|
||||
void *ptr;
|
||||
} mysqli_object; /* extends zend_object */
|
||||
|
||||
#define MYSQLI_PR_MAIN 0
|
||||
#define MYSQLI_PR_MYSQL 1
|
||||
#define MYSQLI_PR_QUERY 2
|
||||
#define MYSQLI_PR_QUERY_RESULT 3
|
||||
#define MYSQLI_PR_STMT 4
|
||||
#define MYSQLI_PR_STMT_RESULT 5
|
||||
#define MYSQLI_PR_RESULT 6
|
||||
#define MYSQLI_PR_COMMAND 7
|
||||
|
||||
|
||||
#define phpext_mysqli_ptr &mysqli_module_entry
|
||||
|
||||
#ifdef PHP_WIN32
|
||||
#define PHP_MYSQLI_API __declspec(dllexport)
|
||||
#else
|
||||
#define PHP_MYSQLI_API
|
||||
#endif
|
||||
|
||||
#ifdef ZTS
|
||||
#include "TSRM.h"
|
||||
#endif
|
||||
|
||||
#define PHP_MYSQLI_EXPORT(__type) PHP_MYSQLI_API __type
|
||||
|
||||
extern zend_module_entry mysqli_module_entry;
|
||||
extern function_entry mysqli_functions[];
|
||||
extern function_entry mysqli_link_methods[];
|
||||
extern function_entry mysqli_stmt_methods[];
|
||||
extern function_entry mysqli_result_methods[];
|
||||
extern void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int flag);
|
||||
extern void php_clear_stmt_bind(STMT *stmt);
|
||||
|
||||
zend_class_entry *mysqli_link_class_entry;
|
||||
zend_class_entry *mysqli_stmt_class_entry;
|
||||
zend_class_entry *mysqli_result_class_entry;
|
||||
|
||||
zend_class_entry _mysqli_link_class_entry;
|
||||
zend_class_entry _mysqli_stmt_class_entry;
|
||||
zend_class_entry _mysqli_result_class_entry;
|
||||
|
||||
PHP_MYSQLI_EXPORT(zend_object_value) mysqli_objects_new(zend_class_entry * TSRMLS_DC);
|
||||
|
||||
#define REGISTER_MYSQLI_CLASS_ENTRY(name, mysqli_entry, class_functions) { \
|
||||
INIT_CLASS_ENTRY(_##mysqli_entry,name,class_functions); \
|
||||
_##mysqli_entry.create_object = mysqli_objects_new; \
|
||||
mysqli_entry = zend_register_internal_class(&_##mysqli_entry TSRMLS_CC); \
|
||||
} \
|
||||
|
||||
#define MYSQLI_REGISTER_RESOURCE_EX(__ptr, __zval, __ce) \
|
||||
((mysqli_object *) zend_object_store_get_object(__zval TSRMLS_CC))->ptr = __ptr;
|
||||
|
||||
#define MYSQLI_RETURN_RESOURCE(__ptr, __ce) \
|
||||
Z_TYPE_P(return_value) = IS_OBJECT; \
|
||||
(return_value)->value.obj = mysqli_objects_new(__ce TSRMLS_CC); \
|
||||
MYSQLI_REGISTER_RESOURCE_EX(__ptr, return_value, __ce)
|
||||
|
||||
#define MYSQLI_REGISTER_RESOURCE(__ptr, __ce) \
|
||||
{\
|
||||
zval *object = getThis();\
|
||||
if (!object) {\
|
||||
object = return_value;\
|
||||
Z_TYPE_P(object) = IS_OBJECT;\
|
||||
(object)->value.obj = mysqli_objects_new(__ce TSRMLS_CC);\
|
||||
}\
|
||||
MYSQLI_REGISTER_RESOURCE_EX(__ptr, object, __ce)\
|
||||
}
|
||||
|
||||
#define MYSQLI_FETCH_RESOURCE(__ptr, __type, __prptr, __prtype, __id, __name) \
|
||||
{ \
|
||||
MYSQLI_RESOURCE *my_res; \
|
||||
mysqli_object *intern = (mysqli_object *)zend_object_store_get_object(*(__id) TSRMLS_CC);\
|
||||
if (!(my_res = (MYSQLI_RESOURCE *)intern->ptr)) {\
|
||||
php_error(E_WARNING, "Couldn't fetch %s", intern->zo.ce->name);\
|
||||
RETURN_NULL();\
|
||||
}\
|
||||
__ptr = (__type)my_res->ptr; \
|
||||
__prptr = (__prtype)my_res->prinfo; \
|
||||
if (!strcmp((char *)__name, "mysqli_stmt")) {\
|
||||
if (!((STMT *)__ptr)->stmt->mysql) {\
|
||||
php_error(E_WARNING, "Statement isn't valid anymore");\
|
||||
RETURN_NULL();\
|
||||
}\
|
||||
}\
|
||||
}
|
||||
|
||||
#define MYSQLI_CLEAR_RESOURCE(__id) \
|
||||
{ \
|
||||
mysqli_object *intern = (mysqli_object *)zend_object_store_get_object(*(__id) TSRMLS_CC);\
|
||||
efree(intern->ptr); \
|
||||
intern->ptr = NULL; \
|
||||
}
|
||||
|
||||
#define MYSQLI_RETURN_LONG_LONG(__val) \
|
||||
{ \
|
||||
if ((__val) < LONG_MAX) { \
|
||||
RETURN_LONG((__val)); \
|
||||
} else { \
|
||||
char ret[40]; \
|
||||
sprintf(ret, "%llu", (__val)); \
|
||||
RETURN_STRING(ret,1); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define MYSQLI_STORE_RESULT 0
|
||||
#define MYSQLI_USE_RESULT 1
|
||||
|
||||
/* for mysqli_fetch_assoc */
|
||||
#define MYSQLI_ASSOC 1
|
||||
#define MYSQLI_NUM 2
|
||||
#define MYSQLI_BOTH 3
|
||||
|
||||
/* for mysqli_bind_param */
|
||||
#define MYSQLI_BIND_INT 1
|
||||
#define MYSQLI_BIND_DOUBLE 2
|
||||
#define MYSQLI_BIND_STRING 3
|
||||
#define MYSQLI_BIND_SEND_DATA 4
|
||||
|
||||
/* fetch types */
|
||||
#define FETCH_SIMPLE 1
|
||||
#define FETCH_RESULT 2
|
||||
|
||||
PHP_MYSQLI_API void mysqli_register_link(zval *return_value, void *link TSRMLS_DC);
|
||||
PHP_MYSQLI_API void mysqli_register_stmt(zval *return_value, void *stmt TSRMLS_DC);
|
||||
PHP_MYSQLI_API void mysqli_register_result(zval *return_value, void *result TSRMLS_DC);
|
||||
PHP_MYSQLI_API void php_mysqli_set_error(long mysql_errno, char *mysql_err TSRMLS_DC);
|
||||
|
||||
PHP_MINIT_FUNCTION(mysqli);
|
||||
PHP_MSHUTDOWN_FUNCTION(mysqli);
|
||||
PHP_RINIT_FUNCTION(mysqli);
|
||||
PHP_RSHUTDOWN_FUNCTION(mysqli);
|
||||
PHP_MINFO_FUNCTION(mysqli);
|
||||
|
||||
PHP_FUNCTION(mysqli_affected_rows);
|
||||
PHP_FUNCTION(mysqli_autocommit);
|
||||
PHP_FUNCTION(mysqli_bind_param);
|
||||
PHP_FUNCTION(mysqli_bind_result);
|
||||
PHP_FUNCTION(mysqli_change_user);
|
||||
PHP_FUNCTION(mysqli_character_set_name);
|
||||
PHP_FUNCTION(mysqli_close);
|
||||
PHP_FUNCTION(mysqli_commit);
|
||||
PHP_FUNCTION(mysqli_connect);
|
||||
PHP_FUNCTION(mysqli_data_seek);
|
||||
PHP_FUNCTION(mysqli_debug);
|
||||
PHP_FUNCTION(mysqli_disable_reads_from_master);
|
||||
PHP_FUNCTION(mysqli_disable_rpl_parse);
|
||||
PHP_FUNCTION(mysqli_dump_debug_info);
|
||||
PHP_FUNCTION(mysqli_enable_reads_from_master);
|
||||
PHP_FUNCTION(mysqli_enable_rpl_parse);
|
||||
PHP_FUNCTION(mysqli_errno);
|
||||
PHP_FUNCTION(mysqli_error);
|
||||
PHP_FUNCTION(mysqli_execute);
|
||||
PHP_FUNCTION(mysqli_fetch);
|
||||
PHP_FUNCTION(mysqli_fetch_array);
|
||||
PHP_FUNCTION(mysqli_fetch_assoc);
|
||||
PHP_FUNCTION(mysqli_fetch_object);
|
||||
PHP_FUNCTION(mysqli_fetch_field);
|
||||
PHP_FUNCTION(mysqli_fetch_fields);
|
||||
PHP_FUNCTION(mysqli_fetch_field_direct);
|
||||
PHP_FUNCTION(mysqli_fetch_lengths);
|
||||
PHP_FUNCTION(mysqli_fetch_row);
|
||||
PHP_FUNCTION(mysqli_field_count);
|
||||
PHP_FUNCTION(mysqli_field_seek);
|
||||
PHP_FUNCTION(mysqli_field_tell);
|
||||
PHP_FUNCTION(mysqli_free_result);
|
||||
PHP_FUNCTION(mysqli_get_client_info);
|
||||
PHP_FUNCTION(mysqli_get_host_info);
|
||||
PHP_FUNCTION(mysqli_get_proto_info);
|
||||
PHP_FUNCTION(mysqli_get_server_info);
|
||||
PHP_FUNCTION(mysqli_get_server_version);
|
||||
PHP_FUNCTION(mysqli_info);
|
||||
PHP_FUNCTION(mysqli_insert_id);
|
||||
PHP_FUNCTION(mysqli_init);
|
||||
PHP_FUNCTION(mysqli_kill);
|
||||
PHP_FUNCTION(mysqli_master_query);
|
||||
PHP_FUNCTION(mysqli_num_fields);
|
||||
PHP_FUNCTION(mysqli_num_rows);
|
||||
PHP_FUNCTION(mysqli_options);
|
||||
PHP_FUNCTION(mysqli_param_count);
|
||||
PHP_FUNCTION(mysqli_ping);
|
||||
PHP_FUNCTION(mysqli_prepare);
|
||||
PHP_FUNCTION(mysqli_query);
|
||||
PHP_FUNCTION(mysqli_prepare_result);
|
||||
PHP_FUNCTION(mysqli_profiler);
|
||||
PHP_FUNCTION(mysqli_read_query_result);
|
||||
PHP_FUNCTION(mysqli_real_connect);
|
||||
PHP_FUNCTION(mysqli_real_query);
|
||||
PHP_FUNCTION(mysqli_real_escape_string);
|
||||
PHP_FUNCTION(mysqli_reload);
|
||||
PHP_FUNCTION(mysqli_rollback);
|
||||
PHP_FUNCTION(mysqli_row_seek);
|
||||
PHP_FUNCTION(mysqli_rpl_parse_enabled);
|
||||
PHP_FUNCTION(mysqli_rpl_probe);
|
||||
PHP_FUNCTION(mysqli_rpl_query_type);
|
||||
PHP_FUNCTION(mysqli_select_db);
|
||||
PHP_FUNCTION(mysqli_send_long_data);
|
||||
PHP_FUNCTION(mysqli_send_query);
|
||||
PHP_FUNCTION(mysqli_slave_query);
|
||||
PHP_FUNCTION(mysqli_ssl_set);
|
||||
PHP_FUNCTION(mysqli_stat);
|
||||
PHP_FUNCTION(mysqli_stmt_affected_rows);
|
||||
PHP_FUNCTION(mysqli_stmt_close);
|
||||
PHP_FUNCTION(mysqli_stmt_errno);
|
||||
PHP_FUNCTION(mysqli_stmt_error);
|
||||
PHP_FUNCTION(mysqli_stmt_store_result);
|
||||
PHP_FUNCTION(mysqli_store_result);
|
||||
PHP_FUNCTION(mysqli_thread_id);
|
||||
PHP_FUNCTION(mysqli_thread_safe);
|
||||
PHP_FUNCTION(mysqli_use_result);
|
||||
PHP_FUNCTION(mysqli_warning_count);
|
||||
|
||||
ZEND_BEGIN_MODULE_GLOBALS(mysqli)
|
||||
long default_link;
|
||||
long num_links;
|
||||
long max_links;
|
||||
unsigned int default_port;
|
||||
char *default_host;
|
||||
char *default_user;
|
||||
char *default_pw;
|
||||
char *default_socket;
|
||||
long error_no;
|
||||
char *error_msg;
|
||||
unsigned int profiler;
|
||||
ZEND_END_MODULE_GLOBALS(mysqli)
|
||||
|
||||
#ifdef ZTS
|
||||
#define MyG(v) TSRMG(mysqli_globals_id, zend_mysqli_globals *, v)
|
||||
#else
|
||||
#define MyG(v) (mysqli_globals.v)
|
||||
#endif
|
||||
|
||||
#define my_estrdup(x) (x) ? estrdup(x) : NULL
|
||||
#define my_efree(x) if (x) efree(x)
|
||||
|
||||
ZEND_EXTERN_MODULE_GLOBALS(mysqli);
|
||||
|
||||
#endif /* PHP_MYSQLI.H */
|
||||
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
@@ -1,54 +0,0 @@
|
||||
--TEST--
|
||||
mysqli connect
|
||||
--FILE--
|
||||
<?
|
||||
$user = "root";
|
||||
$passwd = "";
|
||||
$dbname = "test";
|
||||
$test = "";
|
||||
|
||||
/*** test mysqli_connect 127.0.0.1 ***/
|
||||
$link = mysqli_connect("127.0.0.1", $user, $passwd);
|
||||
$test .= ($link) ? "1" : "0";
|
||||
mysqli_close($link);
|
||||
|
||||
/*** test mysqli_connect localhost ***/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
$test .= ($link) ? "1" : "0";
|
||||
mysqli_close($link);
|
||||
|
||||
/*** test mysqli_connect localhost:port ***/
|
||||
$link = mysqli_connect("localhost", $user, $passwd, "", 3306);
|
||||
$test .= ($link) ? "1" : "0";
|
||||
mysqli_close($link);
|
||||
|
||||
/*** test mysqli_real_connect ***/
|
||||
$link = mysqli_init();
|
||||
$test.= (mysqli_real_connect($link, "localhost", $user, $passwd))
|
||||
? "1" : "0";
|
||||
mysqli_close($link);
|
||||
|
||||
/*** test mysqli_real_connect with db ***/
|
||||
$link = mysqli_init();
|
||||
$test .= (mysqli_real_connect($link, "localhost", $user, $passwd, $dbname))
|
||||
? "1" : "0";
|
||||
mysqli_close($link);
|
||||
|
||||
/*** test mysqli_real_connect with port ***/
|
||||
$link = mysqli_init();
|
||||
$test .= (mysqli_real_connect($link, "localhost", $user, $passwd, $dbname, 3306))
|
||||
? "1":"0";
|
||||
mysqli_close($link);
|
||||
|
||||
/*** test mysqli_real_connect compressed ***/
|
||||
$link = mysqli_init();
|
||||
$test .= (mysqli_real_connect($link, "localhost", $user, $passwd, $dbname, 0, NULL, MYSQLI_CLIENT_COMPRESS))
|
||||
? "1" : "0";
|
||||
mysqli_close($link);
|
||||
|
||||
/* todo ssl connections */
|
||||
|
||||
var_dump($test);
|
||||
?>
|
||||
--EXPECT--
|
||||
string(7) "1111111"
|
||||
@@ -1,60 +0,0 @@
|
||||
--TEST--
|
||||
mysqli bind_result 1
|
||||
--FILE--
|
||||
<?php
|
||||
include "connect.inc";
|
||||
|
||||
/*** test mysqli_connect 127.0.0.1 ***/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
|
||||
mysqli_select_db($link, "test");
|
||||
$rc = mysqli_query($link,"DROP TABLE IF EXISTS test_fetch_null");
|
||||
|
||||
$rc = mysqli_query($link,"CREATE TABLE test_fetch_null(col1 tinyint, col2 smallint,
|
||||
col3 int, col4 bigint,
|
||||
col5 float, col6 double,
|
||||
col7 date, col8 time,
|
||||
col9 varbinary(10),
|
||||
col10 varchar(50),
|
||||
col11 char(20))");
|
||||
|
||||
$rc = mysqli_query($link,"INSERT INTO test_fetch_null(col1,col10, col11) VALUES(1,'foo1', 1000),(2,'foo2', 88),(3,'foo3', 389789)");
|
||||
|
||||
$stmt = mysqli_prepare($link, "SELECT col1, col2, col3, col4, col5, col6, col7, col8, col9, col10, col11 from test_fetch_null");
|
||||
mysqli_bind_result($stmt, &$c1, &$c2, &$c3, &$c4, &$c5, &$c6, &$c7, &$c8, &$c9, &$c10, &$c11);
|
||||
mysqli_execute($stmt);
|
||||
|
||||
mysqli_fetch($stmt);
|
||||
|
||||
$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7,$c8,$c9,$c10,$c11);
|
||||
|
||||
var_dump($test);
|
||||
|
||||
mysqli_stmt_close($stmt);
|
||||
mysqli_close($link);
|
||||
?>
|
||||
--EXPECT--
|
||||
array(11) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
NULL
|
||||
[2]=>
|
||||
NULL
|
||||
[3]=>
|
||||
NULL
|
||||
[4]=>
|
||||
NULL
|
||||
[5]=>
|
||||
NULL
|
||||
[6]=>
|
||||
NULL
|
||||
[7]=>
|
||||
NULL
|
||||
[8]=>
|
||||
NULL
|
||||
[9]=>
|
||||
string(4) "foo1"
|
||||
[10]=>
|
||||
string(4) "1000"
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
--TEST--
|
||||
mysqli connect
|
||||
--FILE--
|
||||
<?php
|
||||
include "connect.inc";
|
||||
|
||||
/*** test mysqli_connect 127.0.0.1 ***/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
|
||||
mysqli_select_db($link, "test");
|
||||
|
||||
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_result");
|
||||
mysqli_query($link,"CREATE TABLE test_bind_result(c1 date, c2 time,
|
||||
c3 timestamp(14),
|
||||
c4 year,
|
||||
c5 datetime,
|
||||
c6 timestamp(4),
|
||||
c7 timestamp(6))");
|
||||
|
||||
mysqli_query($link,"INSERT INTO test_bind_result VALUES('2002-01-02',
|
||||
'12:49:00',
|
||||
'2002-01-02 17:46:59',
|
||||
2010,
|
||||
'2010-07-10',
|
||||
'2020','1999-12-29')");
|
||||
|
||||
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_result");
|
||||
|
||||
mysqli_bind_result($stmt,&$c1, &$c2, &$c3, &$c4, &$c5, &$c6, &$c7);
|
||||
mysqli_execute($stmt);
|
||||
mysqli_fetch($stmt);
|
||||
|
||||
$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7);
|
||||
|
||||
var_dump($test);
|
||||
|
||||
mysqli_stmt_close($stmt);
|
||||
mysqli_close($link);
|
||||
?>
|
||||
--EXPECT--
|
||||
array(7) {
|
||||
[0]=>
|
||||
string(10) "2002-01-02"
|
||||
[1]=>
|
||||
string(8) "12:49:00"
|
||||
[2]=>
|
||||
string(19) "2002-01-02 17:46:59"
|
||||
[3]=>
|
||||
int(2010)
|
||||
[4]=>
|
||||
string(19) "2010-07-10 00:00:00"
|
||||
[5]=>
|
||||
string(0) ""
|
||||
[6]=>
|
||||
string(19) "1999-12-29 00:00:00"
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
--TEST--
|
||||
mysqli fetch char/text
|
||||
--FILE--
|
||||
<?php
|
||||
include ("connect.inc");
|
||||
|
||||
/*** test mysqli_connect 127.0.0.1 ***/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
|
||||
mysqli_select_db($link, "test");
|
||||
|
||||
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
|
||||
mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 char(10), c2 text)");
|
||||
|
||||
mysqli_query($link, "INSERT INTO test_bind_fetch VALUES ('1234567890', 'this is a test')");
|
||||
|
||||
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
|
||||
mysqli_bind_result($stmt, &$c1, &$c2);
|
||||
mysqli_execute($stmt);
|
||||
mysqli_fetch($stmt);
|
||||
|
||||
$test = array($c1,$c2);
|
||||
|
||||
var_dump($test);
|
||||
|
||||
mysqli_stmt_close($stmt);
|
||||
mysqli_close($link);
|
||||
?>
|
||||
--EXPECT--
|
||||
array(2) {
|
||||
[0]=>
|
||||
string(10) "1234567890"
|
||||
[1]=>
|
||||
string(14) "this is a test"
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
--TEST--
|
||||
mysqli fetch char/text long
|
||||
--FILE--
|
||||
<?php
|
||||
include "connect.inc";
|
||||
|
||||
/*** test mysqli_connect 127.0.0.1 ***/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
|
||||
mysqli_select_db($link, "test");
|
||||
|
||||
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
|
||||
mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 char(10), c2 text)");
|
||||
|
||||
$a = str_repeat("A1", 32000);
|
||||
|
||||
mysqli_query($link, "INSERT INTO test_bind_fetch VALUES ('1234567890', '$a')");
|
||||
|
||||
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
|
||||
mysqli_bind_result($stmt, &$c1, &$c2);
|
||||
mysqli_execute($stmt);
|
||||
mysqli_fetch($stmt);
|
||||
|
||||
$test[] = $c1;
|
||||
$test[] = ($a == $c2) ? "32K String ok" : "32K String failed";
|
||||
|
||||
var_dump($test);
|
||||
|
||||
mysqli_stmt_close($stmt);
|
||||
mysqli_close($link);
|
||||
?>
|
||||
--EXPECT--
|
||||
array(2) {
|
||||
[0]=>
|
||||
string(10) "1234567890"
|
||||
[1]=>
|
||||
string(13) "32K String ok"
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
--TEST--
|
||||
mysqli fetch long values
|
||||
--FILE--
|
||||
<?php
|
||||
include "connect.inc";
|
||||
|
||||
/*** test mysqli_connect 127.0.0.1 ***/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
|
||||
mysqli_select_db($link, "test");
|
||||
|
||||
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
|
||||
mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 int unsigned,
|
||||
c2 int unsigned,
|
||||
c3 int,
|
||||
c4 int,
|
||||
c5 int,
|
||||
c6 int unsigned,
|
||||
c7 int)");
|
||||
|
||||
mysqli_query($link, "INSERT INTO test_bind_fetch VALUES (-23,35999,NULL,-500,-9999999,-0,0)");
|
||||
|
||||
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
|
||||
mysqli_bind_result($stmt, &$c1, &$c2, &$c3, &$c4, &$c5, &$c6, &$c7);
|
||||
mysqli_execute($stmt);
|
||||
mysqli_fetch($stmt);
|
||||
|
||||
$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7);
|
||||
|
||||
var_dump($test);
|
||||
|
||||
mysqli_stmt_close($stmt);
|
||||
mysqli_close($link);
|
||||
?>
|
||||
--EXPECT--
|
||||
array(7) {
|
||||
[0]=>
|
||||
int(0)
|
||||
[1]=>
|
||||
int(35999)
|
||||
[2]=>
|
||||
NULL
|
||||
[3]=>
|
||||
int(-500)
|
||||
[4]=>
|
||||
int(-9999999)
|
||||
[5]=>
|
||||
int(0)
|
||||
[6]=>
|
||||
int(0)
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
--TEST--
|
||||
mysqli fetch short values
|
||||
--FILE--
|
||||
<?php
|
||||
include "connect.inc";
|
||||
|
||||
/*** test mysqli_connect 127.0.0.1 ***/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
|
||||
mysqli_select_db($link, "test");
|
||||
|
||||
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
|
||||
mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 smallint unsigned,
|
||||
c2 smallint unsigned,
|
||||
c3 smallint,
|
||||
c4 smallint,
|
||||
c5 smallint,
|
||||
c6 smallint unsigned,
|
||||
c7 smallint)");
|
||||
|
||||
mysqli_query($link, "INSERT INTO test_bind_fetch VALUES (-23,35999,NULL,-500,-9999999,+30,0)");
|
||||
|
||||
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
|
||||
mysqli_bind_result($stmt, &$c1, &$c2, &$c3, &$c4, &$c5, &$c6, &$c7);
|
||||
mysqli_execute($stmt);
|
||||
mysqli_fetch($stmt);
|
||||
|
||||
$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7);
|
||||
|
||||
var_dump($test);
|
||||
|
||||
mysqli_stmt_close($stmt);
|
||||
mysqli_close($link);
|
||||
?>
|
||||
--EXPECT--
|
||||
array(7) {
|
||||
[0]=>
|
||||
int(0)
|
||||
[1]=>
|
||||
int(35999)
|
||||
[2]=>
|
||||
NULL
|
||||
[3]=>
|
||||
int(-500)
|
||||
[4]=>
|
||||
int(-32768)
|
||||
[5]=>
|
||||
int(30)
|
||||
[6]=>
|
||||
int(0)
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
--TEST--
|
||||
mysqli fetch tinyint values
|
||||
--FILE--
|
||||
<?php
|
||||
include "connect.inc";
|
||||
|
||||
/*** test mysqli_connect 127.0.0.1 ***/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
|
||||
mysqli_select_db($link, "test");
|
||||
|
||||
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
|
||||
mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 tinyint,
|
||||
c2 tinyint unsigned,
|
||||
c3 tinyint not NULL,
|
||||
c4 tinyint,
|
||||
c5 tinyint,
|
||||
c6 tinyint unsigned,
|
||||
c7 tinyint)");
|
||||
|
||||
mysqli_query($link, "INSERT INTO test_bind_fetch VALUES (-23,300,0,-100,-127,+30,0)");
|
||||
|
||||
$c1 = $c2 = $c3 = $c4 = $c5 = $c6 = $c7 = NULL;
|
||||
|
||||
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
|
||||
mysqli_bind_result($stmt, &$c1, &$c2, &$c3, &$c4, &$c5, &$c6, &$c7);
|
||||
mysqli_execute($stmt);
|
||||
mysqli_fetch($stmt);
|
||||
|
||||
$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7);
|
||||
|
||||
var_dump($test);
|
||||
|
||||
mysqli_stmt_close($stmt);
|
||||
mysqli_close($link);
|
||||
?>
|
||||
--EXPECT--
|
||||
array(7) {
|
||||
[0]=>
|
||||
int(-23)
|
||||
[1]=>
|
||||
int(255)
|
||||
[2]=>
|
||||
int(0)
|
||||
[3]=>
|
||||
int(-100)
|
||||
[4]=>
|
||||
int(-127)
|
||||
[5]=>
|
||||
int(30)
|
||||
[6]=>
|
||||
int(0)
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
--TEST--
|
||||
mysqli fetch bigint values
|
||||
--FILE--
|
||||
<?php
|
||||
include "connect.inc";
|
||||
|
||||
/*** test mysqli_connect 127.0.0.1 ***/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
|
||||
mysqli_select_db($link, "test");
|
||||
|
||||
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
|
||||
mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 bigint default 5,
|
||||
c2 bigint,
|
||||
c3 bigint not NULL,
|
||||
c4 bigint unsigned,
|
||||
c5 bigint unsigned,
|
||||
c6 bigint unsigned,
|
||||
c7 bigint unsigned)");
|
||||
|
||||
mysqli_query($link, "INSERT INTO test_bind_fetch (c2,c3,c4,c5,c6,c7) VALUES (-23,4.0,33333333333333,0,-333333333333,99.9)");
|
||||
|
||||
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
|
||||
mysqli_bind_result($stmt, &$c1, &$c2, &$c3, &$c4, &$c5, &$c6, &$c7);
|
||||
mysqli_execute($stmt);
|
||||
mysqli_fetch($stmt);
|
||||
|
||||
$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7);
|
||||
|
||||
var_dump($test);
|
||||
|
||||
mysqli_stmt_close($stmt);
|
||||
mysqli_close($link);
|
||||
?>
|
||||
--EXPECT--
|
||||
array(7) {
|
||||
[0]=>
|
||||
int(5)
|
||||
[1]=>
|
||||
int(-23)
|
||||
[2]=>
|
||||
int(4)
|
||||
[3]=>
|
||||
string(14) "33333333333333"
|
||||
[4]=>
|
||||
int(0)
|
||||
[5]=>
|
||||
string(13) "-333333333333"
|
||||
[6]=>
|
||||
int(100)
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
--TEST--
|
||||
mysqli fetch float values
|
||||
--FILE--
|
||||
<?php
|
||||
include "connect.inc";
|
||||
|
||||
/*** test mysqli_connect 127.0.0.1 ***/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
|
||||
mysqli_select_db($link, "test");
|
||||
|
||||
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
|
||||
|
||||
mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 float(3),
|
||||
c2 float,
|
||||
c3 float unsigned,
|
||||
c4 float,
|
||||
c5 float,
|
||||
c6 float,
|
||||
c7 float(10) unsigned)");
|
||||
|
||||
|
||||
mysqli_query($link, "INSERT INTO test_bind_fetch (c1,c2,c3,c4,c5,c6,c7) VALUES (3.1415926535,-0.000001, -5, 999999999999,
|
||||
sin(0.6), 1.00000000000001, 888888888888888)");
|
||||
|
||||
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
|
||||
mysqli_bind_result($stmt, &$c1, &$c2, &$c3, &$c4, &$c5, &$c6, &$c7);
|
||||
mysqli_execute($stmt);
|
||||
mysqli_fetch($stmt);
|
||||
|
||||
$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7);
|
||||
|
||||
var_dump($test);
|
||||
|
||||
mysqli_stmt_close($stmt);
|
||||
mysqli_close($link);
|
||||
?>
|
||||
--EXPECT--
|
||||
array(7) {
|
||||
[0]=>
|
||||
float(3.1415927410126)
|
||||
[1]=>
|
||||
float(-9.9999999747524E-7)
|
||||
[2]=>
|
||||
float(0)
|
||||
[3]=>
|
||||
float(999999995904)
|
||||
[4]=>
|
||||
float(0.56464248895645)
|
||||
[5]=>
|
||||
float(1)
|
||||
[6]=>
|
||||
float(888888914608130)
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
--TEST--
|
||||
mysqli fetch mixed values
|
||||
--FILE--
|
||||
<?php
|
||||
include "connect.inc";
|
||||
|
||||
/*** test mysqli_connect 127.0.0.1 ***/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
|
||||
mysqli_select_db($link, "test");
|
||||
|
||||
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_result");
|
||||
|
||||
mysqli_query($link,"CREATE TABLE test_bind_result(c1 tinyint, c2 smallint,
|
||||
c3 int, c4 bigint,
|
||||
c5 float, c6 double,
|
||||
c7 varbinary(10),
|
||||
c8 varchar(50))");
|
||||
|
||||
mysqli_query($link,"INSERT INTO test_bind_result VALUES(19,2999,3999,4999999,
|
||||
2345.6,5678.89563,
|
||||
'foobar','mysql rulez')");
|
||||
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_result");
|
||||
mysqli_bind_result($stmt, &$c1, &$c2, &$c3, &$c4, &$c5, &$c6, &$c7, &$c8);
|
||||
mysqli_execute($stmt);
|
||||
mysqli_fetch($stmt);
|
||||
|
||||
$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7,$c8);
|
||||
|
||||
var_dump($test);
|
||||
|
||||
mysqli_stmt_close($stmt);
|
||||
mysqli_close($link);
|
||||
?>
|
||||
--EXPECT--
|
||||
array(8) {
|
||||
[0]=>
|
||||
int(19)
|
||||
[1]=>
|
||||
int(2999)
|
||||
[2]=>
|
||||
int(3999)
|
||||
[3]=>
|
||||
int(4999999)
|
||||
[4]=>
|
||||
float(2345.6000976563)
|
||||
[5]=>
|
||||
float(5678.89563)
|
||||
[6]=>
|
||||
string(6) "foobar"
|
||||
[7]=>
|
||||
string(11) "mysql rulez"
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
--TEST--
|
||||
mysqli fetch mixed values 2
|
||||
--FILE--
|
||||
<?php
|
||||
include "connect.inc";
|
||||
|
||||
/*** test mysqli_connect 127.0.0.1 ***/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
|
||||
mysqli_select_db($link, "test");
|
||||
|
||||
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_result");
|
||||
|
||||
mysqli_query($link,"CREATE TABLE test_bind_result(c1 tinyint, c2 smallint,
|
||||
c3 int, c4 bigint,
|
||||
c5 float, c6 double,
|
||||
c7 varbinary(10),
|
||||
c8 varchar(10))");
|
||||
|
||||
mysqli_query($link,"INSERT INTO test_bind_result VALUES(120,2999,3999,54,
|
||||
2.6,58.89,
|
||||
'206','6.7')");
|
||||
|
||||
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_result");
|
||||
mysqli_bind_result($stmt, &$c1, &$c2, &$c3, &$c4, &$c5, &$c6, &$c7, &$c8);
|
||||
mysqli_execute($stmt);
|
||||
mysqli_fetch($stmt);
|
||||
|
||||
$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7,$c8);
|
||||
|
||||
var_dump($test);
|
||||
|
||||
mysqli_stmt_close($stmt);
|
||||
mysqli_close($link);
|
||||
?>
|
||||
--EXPECT--
|
||||
array(8) {
|
||||
[0]=>
|
||||
int(120)
|
||||
[1]=>
|
||||
int(2999)
|
||||
[2]=>
|
||||
int(3999)
|
||||
[3]=>
|
||||
int(54)
|
||||
[4]=>
|
||||
float(2.5999999046326)
|
||||
[5]=>
|
||||
float(58.89)
|
||||
[6]=>
|
||||
string(3) "206"
|
||||
[7]=>
|
||||
string(3) "6.7"
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
--TEST--
|
||||
mysqli fetch mixed / mysql_query
|
||||
--FILE--
|
||||
<?php
|
||||
include "connect.inc";
|
||||
|
||||
/*** test mysqli_connect 127.0.0.1 ***/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
|
||||
mysqli_select_db($link, "test");
|
||||
|
||||
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_result");
|
||||
|
||||
mysqli_query($link,"CREATE TABLE test_bind_result(c1 tinyint, c2 smallint,
|
||||
c3 int, c4 bigint,
|
||||
c5 decimal(4,2), c6 double,
|
||||
c7 varbinary(10),
|
||||
c8 varchar(10))");
|
||||
|
||||
mysqli_query($link,"INSERT INTO test_bind_result VALUES(120,2999,3999,54,
|
||||
2.6,58.89,
|
||||
'206','6.7')");
|
||||
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_result");
|
||||
|
||||
$c = array(0,0,0,0,0,0,0,0);
|
||||
mysqli_bind_result($stmt, &$c[0], &$c[1], &$c[2], &$c[3], &$c[4], &$c[5], &$c[6], &$c[7]);
|
||||
mysqli_execute($stmt);
|
||||
mysqli_fetch($stmt);
|
||||
mysqli_fetch($stmt);
|
||||
mysqli_stmt_close($stmt);
|
||||
|
||||
$result = mysqli_query($link, "select * from test_bind_result");
|
||||
$d = mysqli_fetch_row($result);
|
||||
mysqli_free_result($result);
|
||||
|
||||
$test = "";
|
||||
for ($i=0; $i < count($c); $i++)
|
||||
$test .= ($c[0] == $d[0]) ? "1" : "0";
|
||||
|
||||
var_dump($test);
|
||||
|
||||
mysqli_close($link);
|
||||
?>
|
||||
--EXPECT--
|
||||
string(8) "11111111"
|
||||
@@ -1,66 +0,0 @@
|
||||
--TEST--
|
||||
mysqli autocommit/commit/rollback
|
||||
--SKIPIF--
|
||||
<?php
|
||||
include "connect.inc";
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
$result = mysqli_query($link, "SHOW VARIABLES LIKE 'have_innodb'");
|
||||
$row = mysqli_fetch_row($result);
|
||||
mysqli_free_result($result);
|
||||
mysqli_close($link);
|
||||
|
||||
if ($row[1] == "DISABLED" || $row[1] == "NO") {
|
||||
printf ("skip innodb support is not installed or enabled.");
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
include "connect.inc";
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
|
||||
mysqli_select_db($link, "test");
|
||||
|
||||
mysqli_autocommit($link, TRUE);
|
||||
|
||||
mysqli_query($link,"DROP TABLE IF EXISTS ac_01");
|
||||
|
||||
mysqli_query($link,"CREATE TABLE ac_01(a int, b varchar(10)) type=InnoDB");
|
||||
|
||||
mysqli_query($link, "INSERT INTO ac_01 VALUES (1, 'foobar')");
|
||||
mysqli_autocommit($link, FALSE);
|
||||
mysqli_query($link, "DELETE FROM ac_01");
|
||||
mysqli_query($link, "INSERT INTO ac_01 VALUES (2, 'egon')");
|
||||
|
||||
mysqli_rollback($link);
|
||||
|
||||
$result = mysqli_query($link, "SELECT * FROM ac_01");
|
||||
$row = mysqli_fetch_row($result);
|
||||
mysqli_free_result($result);
|
||||
|
||||
var_dump($row);
|
||||
|
||||
mysqli_query($link, "DELETE FROM ac_01");
|
||||
mysqli_query($link, "INSERT INTO ac_01 VALUES (2, 'egon')");
|
||||
mysqli_commit($link);
|
||||
|
||||
$result = mysqli_query($link, "SELECT * FROM ac_01");
|
||||
$row = mysqli_fetch_row($result);
|
||||
mysqli_free_result($result);
|
||||
|
||||
var_dump($row);
|
||||
|
||||
mysqli_close($link);
|
||||
?>
|
||||
--EXPECT--
|
||||
array(2) {
|
||||
[0]=>
|
||||
string(1) "1"
|
||||
[1]=>
|
||||
string(6) "foobar"
|
||||
}
|
||||
array(2) {
|
||||
[0]=>
|
||||
string(1) "2"
|
||||
[1]=>
|
||||
string(4) "egon"
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
--TEST--
|
||||
mysqli autocommit/commit/rollback with myisam
|
||||
--SKIPIF--
|
||||
<?php
|
||||
include "connect.inc";
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
$result = mysqli_query($link, "SHOW VARIABLES LIKE 'have_innodb'");
|
||||
$row = mysqli_fetch_row($result);
|
||||
mysqli_free_result($result);
|
||||
mysqli_close($link);
|
||||
|
||||
if ($row[1] == "NO") {
|
||||
printf ("skip innodb support not installed.");
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
include "connect.inc";
|
||||
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
|
||||
mysqli_select_db($link, "test");
|
||||
|
||||
mysqli_autocommit($link, TRUE);
|
||||
|
||||
mysqli_query($link,"DROP TABLE IF EXISTS ac_01");
|
||||
|
||||
mysqli_query($link,"CREATE TABLE ac_01(a int, b varchar(10))");
|
||||
|
||||
mysqli_query($link, "INSERT INTO ac_01 VALUES (1, 'foobar')");
|
||||
mysqli_autocommit($link, FALSE);
|
||||
|
||||
mysqli_query($link, "DELETE FROM ac_01");
|
||||
mysqli_query($link, "INSERT INTO ac_01 VALUES (2, 'egon')");
|
||||
|
||||
mysqli_rollback($link);
|
||||
|
||||
$result = mysqli_query($link, "SELECT * FROM ac_01");
|
||||
$row = mysqli_fetch_row($result);
|
||||
mysqli_free_result($result);
|
||||
|
||||
var_dump($row);
|
||||
|
||||
mysqli_query($link, "DELETE FROM ac_01");
|
||||
mysqli_query($link, "INSERT INTO ac_01 VALUES (2, 'egon')");
|
||||
mysqli_commit($link);
|
||||
|
||||
$result = mysqli_query($link, "SELECT * FROM ac_01");
|
||||
$row = mysqli_fetch_row($result);
|
||||
mysqli_free_result($result);
|
||||
|
||||
var_dump($row);
|
||||
|
||||
mysqli_close($link);
|
||||
?>
|
||||
--EXPECT--
|
||||
array(2) {
|
||||
[0]=>
|
||||
string(1) "2"
|
||||
[1]=>
|
||||
string(4) "egon"
|
||||
}
|
||||
array(2) {
|
||||
[0]=>
|
||||
string(1) "2"
|
||||
[1]=>
|
||||
string(4) "egon"
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
--TEST--
|
||||
mysqli fetch user variable
|
||||
--FILE--
|
||||
<?php
|
||||
include "connect.inc";
|
||||
|
||||
/*** test mysqli_connect 127.0.0.1 ***/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
|
||||
mysqli_select_db($link, "test");
|
||||
|
||||
mysqli_query($link, "SET @dummy='foobar'");
|
||||
|
||||
$stmt = mysqli_prepare($link, "SELECT @dummy");
|
||||
mysqli_bind_result($stmt, &$dummy);
|
||||
mysqli_execute($stmt);
|
||||
mysqli_fetch($stmt);
|
||||
|
||||
var_dump($dummy);
|
||||
|
||||
mysqli_stmt_close($stmt);
|
||||
mysqli_close($link);
|
||||
?>
|
||||
--EXPECT--
|
||||
string(6) "foobar"
|
||||
@@ -1,30 +0,0 @@
|
||||
--TEST--
|
||||
mysqli fetch functions
|
||||
--FILE--
|
||||
<?php
|
||||
include "connect.inc";
|
||||
|
||||
/*** test mysqli_connect 127.0.0.1 ***/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
|
||||
mysqli_select_db($link, "test");
|
||||
|
||||
$stmt = mysqli_prepare($link, "SELECT current_user(), database()");
|
||||
mysqli_bind_result($stmt, &$c0, &$c1);
|
||||
mysqli_execute($stmt);
|
||||
|
||||
mysqli_fetch($stmt);
|
||||
|
||||
$test = array($c0, $c1);
|
||||
|
||||
var_dump($test);
|
||||
|
||||
mysqli_close($link);
|
||||
?>
|
||||
--EXPECT--
|
||||
array(2) {
|
||||
[0]=>
|
||||
string(14) "root@localhost"
|
||||
[1]=>
|
||||
string(4) "test"
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
--TEST--
|
||||
mysqli fetch system variables
|
||||
--FILE--
|
||||
<?php
|
||||
include "connect.inc";
|
||||
|
||||
/*** test mysqli_connect 127.0.0.1 ***/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
|
||||
mysqli_select_db($link, "test");
|
||||
|
||||
mysqli_query($link, "SET AUTOCOMMIT=0");
|
||||
|
||||
$stmt = mysqli_prepare($link, "SELECT @@autocommit");
|
||||
mysqli_bind_result($stmt, &$c0);
|
||||
mysqli_execute($stmt);
|
||||
|
||||
mysqli_fetch($stmt);
|
||||
|
||||
var_dump($c0);
|
||||
|
||||
mysqli_close($link);
|
||||
?>
|
||||
--EXPECT--
|
||||
int(0)
|
||||
@@ -1,68 +0,0 @@
|
||||
--TEST--
|
||||
mysqli fetch (bind_param + bind_result)
|
||||
--FILE--
|
||||
<?php
|
||||
include "connect.inc";
|
||||
|
||||
/*** test mysqli_connect 127.0.0.1 ***/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
|
||||
mysqli_select_db($link, "test");
|
||||
$rc = mysqli_query($link,"DROP TABLE IF EXISTS insert_read");
|
||||
|
||||
$rc = mysqli_query($link,"CREATE TABLE insert_read(col1 tinyint, col2 smallint,
|
||||
col3 int, col4 bigint,
|
||||
col5 float, col6 double,
|
||||
col7 date, col8 time,
|
||||
col9 varbinary(10),
|
||||
col10 varchar(50),
|
||||
col11 char(20))");
|
||||
|
||||
$stmt= mysqli_prepare($link,"INSERT INTO insert_read(col1,col10, col11) VALUES(?,?,?)");
|
||||
mysqli_bind_param($stmt, &$c1, MYSQLI_BIND_INT, &$c2, MYSQLI_BIND_STRING, &$c3, MYSQLI_BIND_STRING);
|
||||
|
||||
$c1 = 1;
|
||||
$c2 = "foo";
|
||||
$c3 = "foobar";
|
||||
|
||||
mysqli_execute($stmt);
|
||||
mysqli_stmt_close($stmt);
|
||||
|
||||
$stmt = mysqli_prepare($link, "SELECT col1, col2, col3, col4, col5, col6, col7, col8, col9, col10, col11 from insert_read");
|
||||
mysqli_bind_result($stmt, &$c1, &$c2, &$c3, &$c4, &$c5, &$c6, &$c7, &$c8, &$c9, &$c10, &$c11);
|
||||
mysqli_execute($stmt);
|
||||
|
||||
mysqli_fetch($stmt);
|
||||
|
||||
$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7,$c8,$c9,$c10,$c11);
|
||||
|
||||
var_dump($test);
|
||||
|
||||
mysqli_stmt_close($stmt);
|
||||
mysqli_close($link);
|
||||
?>
|
||||
--EXPECT--
|
||||
array(11) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
NULL
|
||||
[2]=>
|
||||
NULL
|
||||
[3]=>
|
||||
NULL
|
||||
[4]=>
|
||||
NULL
|
||||
[5]=>
|
||||
NULL
|
||||
[6]=>
|
||||
NULL
|
||||
[7]=>
|
||||
NULL
|
||||
[8]=>
|
||||
NULL
|
||||
[9]=>
|
||||
string(3) "foo"
|
||||
[10]=>
|
||||
string(6) "foobar"
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
--TEST--
|
||||
mysqli bind_param/bind_result date
|
||||
--FILE--
|
||||
<?php
|
||||
include "connect.inc";
|
||||
|
||||
/*** test mysqli_connect 127.0.0.1 ***/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
|
||||
mysqli_select_db($link, "test");
|
||||
|
||||
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_result");
|
||||
mysqli_query($link,"CREATE TABLE test_bind_result(c1 date, c2 time,
|
||||
c3 timestamp(14),
|
||||
c4 year,
|
||||
c5 datetime,
|
||||
c6 timestamp(4),
|
||||
c7 timestamp(6))");
|
||||
|
||||
$stmt = mysqli_prepare($link, "INSERT INTO test_bind_result VALUES (?,?,?,?,?,?,?)");
|
||||
mysqli_bind_param($stmt, &$d1, MYSQLI_BIND_STRING,
|
||||
&$d2, MYSQLI_BIND_STRING,
|
||||
&$d3, MYSQLI_BIND_STRING,
|
||||
&$d4, MYSQLI_BIND_STRING,
|
||||
&$d5, MYSQLI_BIND_STRING,
|
||||
&$d6, MYSQLI_BIND_STRING,
|
||||
&$d7, MYSQLI_BIND_STRING);
|
||||
|
||||
$d1 = '2002-01-02';
|
||||
$d2 = '12:49:00';
|
||||
$d3 = '2002-01-02 17:46:59';
|
||||
$d4 = 2010;
|
||||
$d5 ='2010-07-10';
|
||||
$d6 = '2020';
|
||||
$d7 = '1999-12-29';
|
||||
|
||||
mysqli_execute($stmt);
|
||||
mysqli_stmt_close($stmt);
|
||||
|
||||
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_result");
|
||||
|
||||
mysqli_bind_result($stmt,&$c1, &$c2, &$c3, &$c4, &$c5, &$c6, &$c7);
|
||||
|
||||
mysqli_execute($stmt);
|
||||
mysqli_fetch($stmt);
|
||||
|
||||
$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7);
|
||||
|
||||
var_dump($test);
|
||||
|
||||
mysqli_stmt_close($stmt);
|
||||
mysqli_close($link);
|
||||
?>
|
||||
--EXPECT--
|
||||
array(7) {
|
||||
[0]=>
|
||||
string(10) "2002-01-02"
|
||||
[1]=>
|
||||
string(8) "12:49:00"
|
||||
[2]=>
|
||||
string(19) "2002-01-02 17:46:59"
|
||||
[3]=>
|
||||
int(2010)
|
||||
[4]=>
|
||||
string(19) "2010-07-10 00:00:00"
|
||||
[5]=>
|
||||
string(0) ""
|
||||
[6]=>
|
||||
string(19) "1999-12-29 00:00:00"
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
--TEST--
|
||||
mysqli bind_param+bind_result char/text
|
||||
--FILE--
|
||||
<?php
|
||||
include "connect.inc";
|
||||
|
||||
/*** test mysqli_connect 127.0.0.1 ***/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
|
||||
mysqli_select_db($link, "test");
|
||||
|
||||
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
|
||||
mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 char(10), c2 text)");
|
||||
|
||||
$stmt = mysqli_prepare($link, "INSERT INTO test_bind_fetch VALUES (?,?)");
|
||||
mysqli_bind_param($stmt, &$q1, MYSQLI_BIND_STRING, &$q2, MYSQLI_BIND_STRING);
|
||||
$q1 = "1234567890";
|
||||
$q2 = "this is a test";
|
||||
mysqli_execute($stmt);
|
||||
mysqli_stmt_close($stmt);
|
||||
|
||||
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
|
||||
mysqli_bind_result($stmt, &$c1, &$c2);
|
||||
mysqli_execute($stmt);
|
||||
mysqli_fetch($stmt);
|
||||
|
||||
$test = array($c1,$c2);
|
||||
|
||||
var_dump($test);
|
||||
|
||||
mysqli_stmt_close($stmt);
|
||||
mysqli_close($link);
|
||||
?>
|
||||
--EXPECT--
|
||||
array(2) {
|
||||
[0]=>
|
||||
string(10) "1234567890"
|
||||
[1]=>
|
||||
string(14) "this is a test"
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
--TEST--
|
||||
mysqli bind_param/bind_result char/text long
|
||||
--FILE--
|
||||
<?php
|
||||
include "connect.inc";
|
||||
|
||||
/*** test mysqli_connect 127.0.0.1 ***/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
|
||||
mysqli_select_db($link, "test");
|
||||
|
||||
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
|
||||
mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 char(10), c2 text)");
|
||||
|
||||
|
||||
$stmt = mysqli_prepare($link, "INSERT INTO test_bind_fetch VALUES (?,?)");
|
||||
mysqli_bind_param($stmt, &$a1, MYSQLI_BIND_STRING, &$a2, MYSQLI_BIND_STRING);
|
||||
|
||||
$a1 = "1234567890";
|
||||
$a2 = str_repeat("A1", 32000);
|
||||
|
||||
mysqli_execute($stmt);
|
||||
mysqli_stmt_close($stmt);
|
||||
|
||||
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
|
||||
mysqli_bind_result($stmt, &$c1, &$c2);
|
||||
mysqli_execute($stmt);
|
||||
mysqli_fetch($stmt);
|
||||
|
||||
$test[] = $c1;
|
||||
$test[] = ($a2 == $c2) ? "32K String ok" : "32K String failed";
|
||||
|
||||
var_dump($test);
|
||||
|
||||
mysqli_stmt_close($stmt);
|
||||
mysqli_close($link);
|
||||
?>
|
||||
--EXPECT--
|
||||
array(2) {
|
||||
[0]=>
|
||||
string(10) "1234567890"
|
||||
[1]=>
|
||||
string(13) "32K String ok"
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
--TEST--
|
||||
mysqli bind_param/bind_prepare fetch long values
|
||||
--FILE--
|
||||
<?php
|
||||
include "connect.inc";
|
||||
|
||||
/*** test mysqli_connect 127.0.0.1 ***/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
|
||||
mysqli_select_db($link, "test");
|
||||
|
||||
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
|
||||
mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 int unsigned,
|
||||
c2 int unsigned,
|
||||
c3 int,
|
||||
c4 int,
|
||||
c5 int,
|
||||
c6 int unsigned,
|
||||
c7 int)");
|
||||
|
||||
$stmt = mysqli_prepare($link, "INSERT INTO test_bind_fetch VALUES (?,?,?,?,?,?,?)");
|
||||
mysqli_bind_param($stmt, &$c1,MYSQLI_BIND_INT,&$c2,MYSQLI_BIND_INT,&$c3,MYSQLI_BIND_INT,
|
||||
&$c4,MYSQLI_BIND_INT,&$c5,MYSQLI_BIND_INT,&$c6,MYSQLI_BIND_INT,
|
||||
&$c7, MYSQLI_BIND_INT);
|
||||
$c1 = -23;
|
||||
$c2 = 35999;
|
||||
$c3 = NULL;
|
||||
$c4 = -500;
|
||||
$c5 = -9999999;
|
||||
$c6 = -0;
|
||||
$c7 = 0;
|
||||
|
||||
mysqli_execute($stmt);
|
||||
mysqli_stmt_close($stmt);
|
||||
|
||||
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
|
||||
mysqli_bind_result($stmt, &$c1, &$c2, &$c3, &$c4, &$c5, &$c6, &$c7);
|
||||
mysqli_execute($stmt);
|
||||
mysqli_fetch($stmt);
|
||||
|
||||
$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7);
|
||||
|
||||
var_dump($test);
|
||||
|
||||
mysqli_stmt_close($stmt);
|
||||
mysqli_close($link);
|
||||
?>
|
||||
--EXPECT--
|
||||
array(7) {
|
||||
[0]=>
|
||||
int(0)
|
||||
[1]=>
|
||||
int(35999)
|
||||
[2]=>
|
||||
NULL
|
||||
[3]=>
|
||||
int(-500)
|
||||
[4]=>
|
||||
int(-9999999)
|
||||
[5]=>
|
||||
int(0)
|
||||
[6]=>
|
||||
int(0)
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
--TEST--
|
||||
mysqli bind_param/bind_result short values
|
||||
--FILE--
|
||||
<?php
|
||||
include "connect.inc";
|
||||
|
||||
/*** test mysqli_connect 127.0.0.1 ***/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
|
||||
mysqli_select_db($link, "test");
|
||||
|
||||
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
|
||||
mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 smallint unsigned,
|
||||
c2 smallint unsigned,
|
||||
c3 smallint,
|
||||
c4 smallint,
|
||||
c5 smallint,
|
||||
c6 smallint unsigned,
|
||||
c7 smallint)");
|
||||
|
||||
$stmt = mysqli_prepare($link, "INSERT INTO test_bind_fetch VALUES (?,?,?,?,?,?,?)");
|
||||
mysqli_bind_param($stmt, &$c1,MYSQLI_BIND_INT,&$c2,MYSQLI_BIND_INT,&$c3,MYSQLI_BIND_INT,
|
||||
&$c4,MYSQLI_BIND_INT,&$c5,MYSQLI_BIND_INT,&$c6,MYSQLI_BIND_INT,
|
||||
&$c7, MYSQLI_BIND_INT);
|
||||
|
||||
$c1 = -23;
|
||||
$c2 = 35999;
|
||||
$c3 = NULL;
|
||||
$c4 = -500;
|
||||
$c5 = -9999999;
|
||||
$c6 = -0;
|
||||
$c7 = 0;
|
||||
|
||||
mysqli_execute($stmt);
|
||||
mysqli_stmt_close($stmt);
|
||||
|
||||
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
|
||||
mysqli_bind_result($stmt, &$c1, &$c2, &$c3, &$c4, &$c5, &$c6, &$c7);
|
||||
mysqli_execute($stmt);
|
||||
mysqli_fetch($stmt);
|
||||
|
||||
$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7);
|
||||
|
||||
var_dump($test);
|
||||
|
||||
mysqli_stmt_close($stmt);
|
||||
mysqli_close($link);
|
||||
?>
|
||||
--EXPECT--
|
||||
array(7) {
|
||||
[0]=>
|
||||
int(0)
|
||||
[1]=>
|
||||
int(35999)
|
||||
[2]=>
|
||||
NULL
|
||||
[3]=>
|
||||
int(-500)
|
||||
[4]=>
|
||||
int(-32768)
|
||||
[5]=>
|
||||
int(0)
|
||||
[6]=>
|
||||
int(0)
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
--TEST--
|
||||
mysqli bind_param/bind_result tinyint values
|
||||
--FILE--
|
||||
<?php
|
||||
include "connect.inc";
|
||||
|
||||
/*** test mysqli_connect 127.0.0.1 ***/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
|
||||
mysqli_select_db($link, "test");
|
||||
|
||||
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
|
||||
mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 tinyint,
|
||||
c2 tinyint unsigned,
|
||||
c3 tinyint not NULL,
|
||||
c4 tinyint,
|
||||
c5 tinyint,
|
||||
c6 tinyint unsigned,
|
||||
c7 tinyint)");
|
||||
|
||||
$stmt = mysqli_prepare ($link, "INSERT INTO test_bind_fetch VALUES(?,?,?,?,?,?,?)");
|
||||
mysqli_bind_param($stmt,&$c1, MYSQLI_BIND_INT,&$c2, MYSQLI_BIND_INT,&$c3, MYSQLI_BIND_INT,&$c4, MYSQLI_BIND_INT,
|
||||
&$c5, MYSQLI_BIND_INT,&$c6, MYSQLI_BIND_INT,&$c7, MYSQLI_BIND_INT);
|
||||
|
||||
$c1 = -23;
|
||||
$c2 = 300;
|
||||
$c3 = 0;
|
||||
$c4 = -100;
|
||||
$c5 = -127;
|
||||
$c6 = 30;
|
||||
$c7 = 0;
|
||||
|
||||
mysqli_execute($stmt);
|
||||
mysqli_stmt_close($stmt);
|
||||
|
||||
mysqli_query($link, "INSERT INTO test_bind_fetch VALUES (-23,300,0,-100,-127,+30,0)");
|
||||
|
||||
$c1 = $c2 = $c3 = $c4 = $c5 = $c6 = $c7 = NULL;
|
||||
|
||||
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
|
||||
mysqli_bind_result($stmt, &$c1, &$c2, &$c3, &$c4, &$c5, &$c6, &$c7);
|
||||
mysqli_execute($stmt);
|
||||
mysqli_fetch($stmt);
|
||||
|
||||
$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7);
|
||||
|
||||
var_dump($test);
|
||||
|
||||
mysqli_stmt_close($stmt);
|
||||
mysqli_close($link);
|
||||
?>
|
||||
--EXPECT--
|
||||
array(7) {
|
||||
[0]=>
|
||||
int(-23)
|
||||
[1]=>
|
||||
int(255)
|
||||
[2]=>
|
||||
int(0)
|
||||
[3]=>
|
||||
int(-100)
|
||||
[4]=>
|
||||
int(-127)
|
||||
[5]=>
|
||||
int(30)
|
||||
[6]=>
|
||||
int(0)
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
--TEST--
|
||||
mysqli bind_param/bind_result with send_long_data
|
||||
--FILE--
|
||||
<?php
|
||||
$user = "root";
|
||||
$passwd = "";
|
||||
|
||||
|
||||
/*** test mysqli_connect 127.0.0.1 ***/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
|
||||
mysqli_select_db($link, "test");
|
||||
|
||||
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
|
||||
mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 varchar(10), c2 text)");
|
||||
|
||||
$stmt = mysqli_prepare ($link, "INSERT INTO test_bind_fetch VALUES (?,?)");
|
||||
mysqli_bind_param($stmt,&$c1, MYSQLI_BIND_STRING, &$c2, MYSQLI_BIND_SEND_DATA);
|
||||
|
||||
$c1 = "Hello World";
|
||||
|
||||
mysqli_send_long_data($stmt, 2, "This is the first sentence.");
|
||||
mysqli_send_long_data($stmt, 2, " And this is the second sentence.");
|
||||
mysqli_send_long_data($stmt, 2, " And finally this is the last sentence.");
|
||||
|
||||
mysqli_execute($stmt);
|
||||
mysqli_stmt_close($stmt);
|
||||
|
||||
$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch");
|
||||
mysqli_bind_result($stmt, &$d1, &$d2);
|
||||
mysqli_execute($stmt);
|
||||
mysqli_fetch($stmt);
|
||||
|
||||
$test = array($d1,$d2);
|
||||
|
||||
var_dump($test);
|
||||
|
||||
mysqli_stmt_close($stmt);
|
||||
|
||||
mysqli_close($link);
|
||||
?>
|
||||
--EXPECT--
|
||||
array(2) {
|
||||
[0]=>
|
||||
string(10) "Hello Worl"
|
||||
[1]=>
|
||||
string(99) "This is the first sentence. And this is the second sentence. And finally this is the last sentence."
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
--TEST--
|
||||
function test: mysqli_character_set_name
|
||||
--FILE--
|
||||
<?php
|
||||
$user = "root";
|
||||
$passwd = "";
|
||||
|
||||
|
||||
/*** test mysqli_connect 127.0.0.1 ***/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
|
||||
$cset = substr(mysqli_character_set_name($link),0,6);
|
||||
|
||||
var_dump($cset);
|
||||
|
||||
mysqli_close($link);
|
||||
?>
|
||||
--EXPECT--
|
||||
string(6) "latin1"
|
||||
@@ -1,25 +0,0 @@
|
||||
--TEST--
|
||||
function test: mysqli_affected_rows
|
||||
--FILE--
|
||||
<?php
|
||||
$user = "root";
|
||||
$passwd = "";
|
||||
|
||||
|
||||
/*** test mysqli_connect 127.0.0.1 ***/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
|
||||
mysqli_select_db($link, "test");
|
||||
|
||||
mysqli_query($link, "drop table if exists general_test");
|
||||
mysqli_query($link, "create table general_test (a int)");
|
||||
mysqli_query($link, "insert into general_test values (1),(2),(3)");
|
||||
|
||||
$afc = mysqli_affected_rows($link);
|
||||
|
||||
var_dump($afc);
|
||||
|
||||
mysqli_close($link);
|
||||
?>
|
||||
--EXPECT--
|
||||
int(3)
|
||||
@@ -1,24 +0,0 @@
|
||||
--TEST--
|
||||
function test: mysqli_errno
|
||||
--FILE--
|
||||
<?php
|
||||
$user = "root";
|
||||
$passwd = "";
|
||||
|
||||
/*** test mysqli_connect 127.0.0.1 ***/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
$errno = mysqli_errno($link);
|
||||
var_dump($errno);
|
||||
|
||||
mysqli_select_db($link, "test");
|
||||
|
||||
mysqli_query($link, "select * from non_exisiting_table");
|
||||
$errno = mysqli_errno($link);
|
||||
|
||||
var_dump($errno);
|
||||
|
||||
mysqli_close($link);
|
||||
?>
|
||||
--EXPECT--
|
||||
int(0)
|
||||
int(1146)
|
||||
@@ -1,24 +0,0 @@
|
||||
--TEST--
|
||||
function test: mysqli_error
|
||||
--FILE--
|
||||
<?php
|
||||
$user = "root";
|
||||
$passwd = "";
|
||||
|
||||
/*** test mysqli_connect 127.0.0.1 ***/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
$error = mysqli_error($link);
|
||||
var_dump($error);
|
||||
|
||||
mysqli_select_db($link, "test");
|
||||
|
||||
mysqli_query($link, "select * from non_exisiting_table");
|
||||
$error = mysqli_error($link);
|
||||
|
||||
var_dump($error);
|
||||
|
||||
mysqli_close($link);
|
||||
?>
|
||||
--EXPECT--
|
||||
string(0) ""
|
||||
string(46) "Table 'test.non_exisiting_table' doesn't exist"
|
||||
@@ -1,25 +0,0 @@
|
||||
--TEST--
|
||||
function test: mysqli_info
|
||||
--FILE--
|
||||
<?php
|
||||
$user = "root";
|
||||
$passwd = "";
|
||||
|
||||
|
||||
/*** test mysqli_connect 127.0.0.1 ***/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
|
||||
mysqli_select_db($link, "test");
|
||||
|
||||
mysqli_query($link, "drop table if exists general_test");
|
||||
mysqli_query($link, "create table general_test (a int)");
|
||||
mysqli_query($link, "insert into general_test values (1),(2),(3)");
|
||||
|
||||
$afc = mysqli_info($link);
|
||||
|
||||
var_dump($afc);
|
||||
|
||||
mysqli_close($link);
|
||||
?>
|
||||
--EXPECT--
|
||||
string(38) "Records: 3 Duplicates: 0 Warnings: 0"
|
||||
@@ -1,19 +0,0 @@
|
||||
--TEST--
|
||||
function test: mysqli_get_host_info
|
||||
--FILE--
|
||||
<?php
|
||||
$user = "root";
|
||||
$passwd = "";
|
||||
|
||||
|
||||
/*** test mysqli_connect 127.0.0.1 ***/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
|
||||
$hinfo = mysqli_get_host_info($link);
|
||||
|
||||
var_dump($hinfo);
|
||||
|
||||
mysqli_close($link);
|
||||
?>
|
||||
--EXPECT--
|
||||
string(25) "Localhost via UNIX socket"
|
||||
@@ -1,19 +0,0 @@
|
||||
--TEST--
|
||||
function test: mysqli_get_proto_info
|
||||
--FILE--
|
||||
<?php
|
||||
$user = "root";
|
||||
$passwd = "";
|
||||
|
||||
|
||||
/*** test mysqli_connect 127.0.0.1 ***/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
|
||||
$pinfo = mysqli_get_proto_info($link);
|
||||
|
||||
var_dump($pinfo);
|
||||
|
||||
mysqli_close($link);
|
||||
?>
|
||||
--EXPECT--
|
||||
int(10)
|
||||
@@ -1,19 +0,0 @@
|
||||
--TEST--
|
||||
function test: mysqli_get_server_info
|
||||
--FILE--
|
||||
<?php
|
||||
$user = "root";
|
||||
$passwd = "";
|
||||
|
||||
|
||||
/*** test mysqli_connect 127.0.0.1 ***/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
|
||||
$sinfo = substr(mysqli_get_server_info($link),0,1);
|
||||
|
||||
var_dump($sinfo);
|
||||
|
||||
mysqli_close($link);
|
||||
?>
|
||||
--EXPECT--
|
||||
string(1) "4"
|
||||
@@ -1,43 +0,0 @@
|
||||
--TEST--
|
||||
function test: mysqli_insert_id()
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
include "connect.inc";
|
||||
|
||||
/*** test mysqli_connect 127.0.0.1 ***/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
|
||||
mysqli_select_db($link, "test");
|
||||
|
||||
mysqli_query($link, "DROP TABLE IF EXISTS t036");
|
||||
|
||||
mysqli_query($link, "CREATE TABLE t036 (a bigint not null auto_increment primary key, b varchar(10))");
|
||||
|
||||
|
||||
mysqli_query($link, "INSERT INTO t036 (b) VALUES ('foo1')");
|
||||
$test[] = mysqli_insert_id($link);
|
||||
|
||||
/* we have to insert more values, cause lexer sets auto_increment to max_int
|
||||
see mysql bug #54. So we don't check for the value, only for type (which must
|
||||
be type string)
|
||||
*/
|
||||
|
||||
mysqli_query($link, "ALTER TABLE t036 AUTO_INCREMENT=9999999999999998");
|
||||
mysqli_query($link, "INSERT INTO t036 (b) VALUES ('foo2')");
|
||||
mysqli_query($link, "INSERT INTO t036 (b) VALUES ('foo3')");
|
||||
mysqli_query($link, "INSERT INTO t036 (b) VALUES ('foo4')");
|
||||
$x = mysqli_insert_id($link);
|
||||
$test[] = is_string($x);
|
||||
|
||||
var_dump($test);
|
||||
|
||||
mysqli_close($link);
|
||||
?>
|
||||
--EXPECT--
|
||||
array(2) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
bool(true)
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
--TEST--
|
||||
function test: mysqli_field_count()
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
include "connect.inc";
|
||||
|
||||
/*** test mysqli_connect 127.0.0.1 ***/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
|
||||
mysqli_select_db($link, "test");
|
||||
|
||||
mysqli_query($link, "DROP TABLE IF EXISTS test_result");
|
||||
|
||||
mysqli_query($link, "CREATE TABLE test_result (a int, b varchar(10))");
|
||||
|
||||
mysqli_query($link, "INSERT INTO test_result VALUES (1, 'foo')");
|
||||
$ir[] = mysqli_field_count($link);
|
||||
|
||||
mysqli_real_query($link, "SELECT * FROM test_result");
|
||||
$ir[] = mysqli_field_count($link);
|
||||
|
||||
|
||||
var_dump($ir);
|
||||
|
||||
mysqli_close($link);
|
||||
?>
|
||||
--EXPECT--
|
||||
array(2) {
|
||||
[0]=>
|
||||
int(0)
|
||||
[1]=>
|
||||
int(2)
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
--TEST--
|
||||
function test: mysqli_num_fields()
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
include "connect.inc";
|
||||
|
||||
/*** test mysqli_connect 127.0.0.1 ***/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
|
||||
mysqli_select_db($link, "test");
|
||||
|
||||
mysqli_query($link, "DROP TABLE IF EXISTS test_result");
|
||||
|
||||
mysqli_query($link, "CREATE TABLE test_result (a int, b varchar(10))");
|
||||
|
||||
mysqli_query($link, "INSERT INTO test_result VALUES (1, 'foo')");
|
||||
|
||||
mysqli_real_query($link, "SELECT * FROM test_result");
|
||||
if (mysqli_field_count($link)) {
|
||||
$result = mysqli_store_result($link);
|
||||
$num = mysqli_num_fields($result);
|
||||
mysqli_free_result($result);
|
||||
}
|
||||
|
||||
var_dump($num);
|
||||
|
||||
mysqli_close($link);
|
||||
?>
|
||||
--EXPECT--
|
||||
int(2)
|
||||
@@ -1,24 +0,0 @@
|
||||
--TEST--
|
||||
function test: mysqli_num_fields() 2
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
include "connect.inc";
|
||||
|
||||
/*** test mysqli_connect 127.0.0.1 ***/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
|
||||
mysqli_real_query($link, "SHOW VARIABLES");
|
||||
|
||||
if (mysqli_field_count($link)) {
|
||||
$result = mysqli_store_result($link);
|
||||
$num = mysqli_num_fields($result);
|
||||
mysqli_free_result($result);
|
||||
}
|
||||
|
||||
var_dump($num);
|
||||
|
||||
mysqli_close($link);
|
||||
?>
|
||||
--EXPECT--
|
||||
int(2)
|
||||
@@ -1,31 +0,0 @@
|
||||
--TEST--
|
||||
function test: mysqli_num_rows()
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
include "connect.inc";
|
||||
|
||||
/*** test mysqli_connect 127.0.0.1 ***/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
|
||||
mysqli_select_db($link, "test");
|
||||
|
||||
mysqli_query($link, "DROP TABLE IF EXISTS test_result");
|
||||
|
||||
mysqli_query($link, "CREATE TABLE test_result (a int, b varchar(10))");
|
||||
|
||||
mysqli_query($link, "INSERT INTO test_result VALUES (1, 'foo')");
|
||||
|
||||
mysqli_real_query($link, "SELECT * FROM test_result");
|
||||
if (mysqli_field_count($link)) {
|
||||
$result = mysqli_store_result($link);
|
||||
$num = mysqli_num_rows($result);
|
||||
mysqli_free_result($result);
|
||||
}
|
||||
|
||||
var_dump($num);
|
||||
|
||||
mysqli_close($link);
|
||||
?>
|
||||
--EXPECT--
|
||||
int(1)
|
||||
@@ -1,24 +0,0 @@
|
||||
--TEST--
|
||||
function test: mysqli_warning_count()
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
include "connect.inc";
|
||||
|
||||
/*** test mysqli_connect 127.0.0.1 ***/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
|
||||
mysqli_select_db($link, "test");
|
||||
|
||||
mysqli_query($link, "DROP TABLE IF EXISTS test_warnings");
|
||||
|
||||
mysqli_query($link, "CREATE TABLE test_warnings (a int not null");
|
||||
|
||||
mysqli_query($link, "INSERT INTO test_warnings VALUES (1),(2),(NULL)");
|
||||
$num = mysqli_warning_count($link);
|
||||
var_dump($num);
|
||||
|
||||
mysqli_close($link);
|
||||
?>
|
||||
--EXPECT--
|
||||
int(1)
|
||||
@@ -1,61 +0,0 @@
|
||||
--TEST--
|
||||
mysqli_fetch_object
|
||||
--FILE--
|
||||
<?php
|
||||
include "connect.inc";
|
||||
|
||||
/*** test mysqli_connect 127.0.0.1 ***/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
|
||||
mysqli_select_db($link, "test");
|
||||
|
||||
mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
|
||||
mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 smallint unsigned,
|
||||
c2 smallint unsigned,
|
||||
c3 smallint,
|
||||
c4 smallint,
|
||||
c5 smallint,
|
||||
c6 smallint unsigned,
|
||||
c7 smallint)");
|
||||
|
||||
$stmt = mysqli_prepare($link, "INSERT INTO test_bind_fetch VALUES (?,?,?,?,?,?,?)");
|
||||
mysqli_bind_param($stmt, &$c1,MYSQLI_BIND_INT,&$c2,MYSQLI_BIND_INT,&$c3,MYSQLI_BIND_INT,
|
||||
&$c4,MYSQLI_BIND_INT,&$c5,MYSQLI_BIND_INT,&$c6,MYSQLI_BIND_INT,
|
||||
&$c7, MYSQLI_BIND_INT);
|
||||
|
||||
$c1 = -23;
|
||||
$c2 = 35999;
|
||||
$c3 = NULL;
|
||||
$c4 = -500;
|
||||
$c5 = -9999999;
|
||||
$c6 = -0;
|
||||
$c7 = 0;
|
||||
|
||||
mysqli_execute($stmt);
|
||||
mysqli_stmt_close($stmt);
|
||||
|
||||
$result = mysqli_query($link, "SELECT * FROM test_bind_fetch");
|
||||
$test = mysqli_fetch_object($result);
|
||||
mysqli_free_result($result);
|
||||
|
||||
var_dump($test);
|
||||
|
||||
mysqli_close($link);
|
||||
?>
|
||||
--EXPECTF--
|
||||
object(stdClass)#%d (7) {
|
||||
["c1"]=>
|
||||
string(1) "0"
|
||||
["c2"]=>
|
||||
string(5) "35999"
|
||||
["c3"]=>
|
||||
NULL
|
||||
["c4"]=>
|
||||
string(4) "-500"
|
||||
["c5"]=>
|
||||
string(6) "-32768"
|
||||
["c6"]=>
|
||||
string(1) "0"
|
||||
["c7"]=>
|
||||
string(1) "0"
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
--TEST--
|
||||
mysqli_bind_param (UPDATE)
|
||||
--FILE--
|
||||
<?php
|
||||
include "connect.inc";
|
||||
|
||||
/*** test mysqli_connect 127.0.0.1 ***/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
|
||||
mysqli_select_db($link, "test");
|
||||
|
||||
mysqli_query($link,"DROP TABLE IF EXISTS test_update");
|
||||
mysqli_query($link,"CREATE TABLE test_update(a varchar(10),
|
||||
b int)");
|
||||
|
||||
mysqli_query($link, "INSERT INTO test_update VALUES ('foo', 2)");
|
||||
|
||||
$stmt = mysqli_prepare($link, "UPDATE test_update SET a=?,b=? WHERE b=?");
|
||||
mysqli_bind_param($stmt, &$c1,MYSQLI_BIND_STRING,&$c2,MYSQLI_BIND_INT, &$c3, MYSQLI_BIND_INT);
|
||||
|
||||
$c1 = "Rasmus";
|
||||
$c2 = 1;
|
||||
$c3 = 2;
|
||||
|
||||
mysqli_execute($stmt);
|
||||
mysqli_stmt_close($stmt);
|
||||
|
||||
$result = mysqli_query($link, "SELECT concat(a, ' is No. ', b) FROM test_update");
|
||||
$test = mysqli_fetch_row($result);
|
||||
mysqli_free_result($result);
|
||||
|
||||
var_dump($test);
|
||||
|
||||
mysqli_close($link);
|
||||
?>
|
||||
--EXPECT--
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(15) "Rasmus is No. 1"
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
--TEST--
|
||||
mysqli_get_server_version
|
||||
--FILE--
|
||||
<?php
|
||||
include "connect.inc";
|
||||
|
||||
/*** test mysqli_connect 127.0.0.1 ***/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
|
||||
$i = mysqli_get_server_version($link);
|
||||
|
||||
$test = $i / $i;
|
||||
|
||||
var_dump($test);
|
||||
|
||||
mysqli_close($link);
|
||||
?>
|
||||
--EXPECT--
|
||||
int(1)
|
||||
@@ -1,28 +0,0 @@
|
||||
--TEST--
|
||||
mysqli_bind_result (SHOW)
|
||||
--FILE--
|
||||
<?php
|
||||
include "connect.inc";
|
||||
|
||||
/*** test mysqli_connect 127.0.0.1 ***/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
|
||||
$stmt = mysqli_prepare($link, "SHOW VARIABLES LIKE 'port'");
|
||||
|
||||
mysqli_execute($stmt);
|
||||
mysqli_bind_result($stmt, &$c1, &$c2);
|
||||
mysqli_fetch($stmt);
|
||||
mysqli_stmt_close($stmt);
|
||||
$test = array ($c1,$c2);
|
||||
|
||||
var_dump($test);
|
||||
|
||||
mysqli_close($link);
|
||||
?>
|
||||
--EXPECT--
|
||||
array(2) {
|
||||
[0]=>
|
||||
string(4) "port"
|
||||
[1]=>
|
||||
string(4) "3306"
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
--TEST--
|
||||
mysqli_stmt_affected_rows (delete)
|
||||
--FILE--
|
||||
<?php
|
||||
include "connect.inc";
|
||||
|
||||
/*** test mysqli_connect 127.0.0.1 ***/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
|
||||
mysqli_select_db($link, "test");
|
||||
|
||||
mysqli_query($link, "DROP TABLE IF EXISTS test_affected");
|
||||
mysqli_query($link, "CREATE TABLE test_affected (foo int)");
|
||||
|
||||
mysqli_query($link, "INSERT INTO test_affected VALUES (1),(2),(3),(4),(5)");
|
||||
|
||||
$stmt = mysqli_prepare($link, "DELETE FROM test_affected WHERE foo=?");
|
||||
mysqli_bind_param($stmt, &$c1, MYSQLI_BIND_INT);
|
||||
|
||||
$c1 = 2;
|
||||
|
||||
mysqli_execute($stmt);
|
||||
$x = mysqli_stmt_affected_rows($stmt);
|
||||
|
||||
mysqli_stmt_close($stmt);
|
||||
var_dump($x==1);
|
||||
|
||||
mysqli_close($link);
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(true)
|
||||
@@ -1,73 +0,0 @@
|
||||
--TEST--
|
||||
mysqli_prepare_result
|
||||
--FILE--
|
||||
<?php
|
||||
include "connect.inc";
|
||||
|
||||
/*** test mysqli_connect 127.0.0.1 ***/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
|
||||
mysqli_select_db($link, "test");
|
||||
|
||||
mysqli_query($link, "DROP TABLE IF EXISTS test_affected");
|
||||
mysqli_query($link, "CREATE TABLE test_affected (foo int, bar varchar(10))");
|
||||
|
||||
mysqli_query($link, "INSERT INTO test_affected VALUES (1, 'Zak'),(2, 'Greant')");
|
||||
|
||||
$stmt = mysqli_prepare($link, "SELECT * FROM test_affected");
|
||||
mysqli_execute($stmt);
|
||||
$result = mysqli_prepare_result($stmt);
|
||||
|
||||
$fields = mysqli_fetch_fields($result);
|
||||
mysqli_free_result($result);
|
||||
|
||||
var_dump($fields);
|
||||
|
||||
mysqli_stmt_close($stmt);
|
||||
mysqli_close($link);
|
||||
?>
|
||||
--EXPECTF--
|
||||
array(2) {
|
||||
[0]=>
|
||||
object(stdClass)#%d (9) {
|
||||
["name"]=>
|
||||
string(3) "foo"
|
||||
["orgname"]=>
|
||||
string(3) "foo"
|
||||
["table"]=>
|
||||
string(13) "test_affected"
|
||||
["orgtable"]=>
|
||||
string(13) "test_affected"
|
||||
["def"]=>
|
||||
string(0) ""
|
||||
["max_length"]=>
|
||||
int(0)
|
||||
["flags"]=>
|
||||
int(32768)
|
||||
["type"]=>
|
||||
int(3)
|
||||
["decimals"]=>
|
||||
int(0)
|
||||
}
|
||||
[1]=>
|
||||
object(stdClass)#%d (9) {
|
||||
["name"]=>
|
||||
string(3) "bar"
|
||||
["orgname"]=>
|
||||
string(3) "bar"
|
||||
["table"]=>
|
||||
string(13) "test_affected"
|
||||
["orgtable"]=>
|
||||
string(13) "test_affected"
|
||||
["def"]=>
|
||||
string(0) ""
|
||||
["max_length"]=>
|
||||
int(0)
|
||||
["flags"]=>
|
||||
int(0)
|
||||
["type"]=>
|
||||
int(253)
|
||||
["decimals"]=>
|
||||
int(0)
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
--TEST--
|
||||
non freed statement test
|
||||
--FILE--
|
||||
<?php
|
||||
include "connect.inc";
|
||||
|
||||
/************************
|
||||
* non freed stamement
|
||||
************************/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
|
||||
$stmt = mysqli_prepare($link, "SELECT CURRENT_USER()");
|
||||
mysqli_execute($stmt);
|
||||
|
||||
mysqli_close($link);
|
||||
printf("Ok\n");
|
||||
?>
|
||||
--EXPECT--
|
||||
Ok
|
||||
@@ -1,20 +0,0 @@
|
||||
--TEST--
|
||||
free statement after close
|
||||
--FILE--
|
||||
<?php
|
||||
include "connect.inc";
|
||||
|
||||
/************************
|
||||
* free statement after close
|
||||
************************/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
|
||||
$stmt1 = mysqli_prepare($link, "SELECT CURRENT_USER()");
|
||||
mysqli_execute($stmt1);
|
||||
|
||||
mysqli_close($link);
|
||||
@mysqli_stmt_close($stmt1);
|
||||
printf("Ok\n");
|
||||
?>
|
||||
--EXPECT--
|
||||
Ok
|
||||
@@ -1,20 +0,0 @@
|
||||
--TEST--
|
||||
call statement after close
|
||||
--FILE--
|
||||
<?php
|
||||
include "connect.inc";
|
||||
|
||||
/************************
|
||||
* statement call after close
|
||||
************************/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
|
||||
$stmt2 = mysqli_prepare($link, "SELECT CURRENT_USER()");
|
||||
|
||||
mysqli_close($link);
|
||||
@mysqli_execute($stmt2);
|
||||
@mysqli_stmt_close($stmt2);
|
||||
printf("Ok\n");
|
||||
?>
|
||||
--EXPECT--
|
||||
Ok
|
||||
@@ -1,18 +0,0 @@
|
||||
--TEST--
|
||||
not freed resultset
|
||||
--FILE--
|
||||
<?php
|
||||
include "connect.inc";
|
||||
|
||||
/************************
|
||||
* non freed resultset
|
||||
************************/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
|
||||
$result = mysqli_query($link, "SELECT CURRENT_USER()");
|
||||
mysqli_close($link);
|
||||
printf("Ok\n");
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
Ok
|
||||
@@ -1,18 +0,0 @@
|
||||
--TEST--
|
||||
free resultset after close
|
||||
--FILE--
|
||||
<?php
|
||||
include "connect.inc";
|
||||
|
||||
/************************
|
||||
* free resultset after close
|
||||
************************/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
|
||||
$result1 = mysqli_query($link, "SELECT CURRENT_USER()");
|
||||
mysqli_close($link);
|
||||
mysqli_free_result($result1);
|
||||
printf("Ok\n");
|
||||
?>
|
||||
--EXPECT--
|
||||
Ok
|
||||
@@ -1,17 +0,0 @@
|
||||
--TEST--
|
||||
free nothing
|
||||
--FILE--
|
||||
<?php
|
||||
include "connect.inc";
|
||||
|
||||
/************************
|
||||
* don't free anything
|
||||
************************/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
|
||||
$result2 = mysqli_query($link, "SELECT CURRENT_USER()");
|
||||
$stmt2 = mysqli_prepare($link, "SELECT CURRENT_USER()");
|
||||
printf("Ok\n");
|
||||
?>
|
||||
--EXPECT--
|
||||
Ok
|
||||
@@ -1,52 +0,0 @@
|
||||
--TEST--
|
||||
mysqli_prepare_result
|
||||
--FILE--
|
||||
<?php
|
||||
include "connect.inc";
|
||||
|
||||
/*** test mysqli_connect 127.0.0.1 ***/
|
||||
$link = mysqli_connect("localhost", $user, $passwd);
|
||||
|
||||
mysqli_select_db($link, "test");
|
||||
|
||||
mysqli_query($link,"DROP TABLE IF EXISTS test_store_result");
|
||||
mysqli_query($link,"CREATE TABLE test_store_result (a int)");
|
||||
|
||||
mysqli_query($link, "INSERT INTO test_store_result VALUES (1),(2),(3)");
|
||||
|
||||
$stmt = mysqli_prepare($link, "SELECT * FROM test_store_result");
|
||||
mysqli_execute($stmt);
|
||||
|
||||
/* this should produce an out of sync error */
|
||||
if ($result = mysqli_query($link, "SELECT * FROM test_store_result")) {
|
||||
mysqli_free_result($result);
|
||||
printf ("Query ok\n");
|
||||
}
|
||||
mysqli_stmt_close($stmt);
|
||||
|
||||
$stmt = mysqli_prepare($link, "SELECT * FROM test_store_result");
|
||||
mysqli_execute($stmt);
|
||||
$result1 = mysqli_prepare_result($stmt);
|
||||
mysqli_stmt_store_result($stmt);
|
||||
|
||||
printf ("Rows: %d\n", mysqli_stmt_affected_rows($stmt));
|
||||
|
||||
/* this should show an error, cause results are not buffered */
|
||||
if ($result = mysqli_query($link, "SELECT * FROM test_store_result")) {
|
||||
$row = mysqli_fetch_row($result);
|
||||
mysqli_free_result($result);
|
||||
}
|
||||
|
||||
|
||||
var_dump($row);
|
||||
|
||||
mysqli_free_result($result1);
|
||||
mysqli_stmt_close($stmt);
|
||||
mysqli_close($link);
|
||||
?>
|
||||
--EXPECT--
|
||||
Rows: 3
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(1) "1"
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
sqlite
|
||||
Wez Furlong, Tal Peer, Marcus Börger
|
||||
@@ -1,14 +0,0 @@
|
||||
This is an extension for the SQLite Embeddable SQL Database Engine.
|
||||
http://www.sqlite.org/
|
||||
|
||||
SQLite is a C library that implements an embeddable SQL database engine.
|
||||
Programs that link with the SQLite library can have SQL database access
|
||||
without running a separate RDBMS process.
|
||||
|
||||
SQLite is not a client library used to connect to a big database server.
|
||||
SQLite is the server. The SQLite library reads and writes directly to and from
|
||||
the database files on disk
|
||||
|
||||
|
||||
|
||||
vim:tw=78:et
|
||||
@@ -1,22 +0,0 @@
|
||||
- Transparent binary encoding of return values from PHP callback functions.
|
||||
|
||||
- Add user-space callback for the authorizer function (this is potentially
|
||||
very slow, so it needs to be implemented carefully).
|
||||
|
||||
- Add user-space callback to handle busy databases.
|
||||
|
||||
- Test-suite
|
||||
|
||||
o Test how robust we are when a user-space function is registered as
|
||||
a callback for a persistent connection in script A, then script B is
|
||||
called that doesn't register the callback but does make use of the
|
||||
function in an SQL query.
|
||||
--> Our test suite doesn't allow us to test persistent connections
|
||||
at this time :/
|
||||
|
||||
- If building a ZTS build, -DTHREADSAFE while compiling libsqlite
|
||||
|
||||
- If building a non-debug build, -DNDEBUG will disable the expensive
|
||||
asserts in the inner loop. (and double performance)
|
||||
|
||||
vim:tw=78
|
||||
@@ -1,37 +0,0 @@
|
||||
This directory contains source code to
|
||||
|
||||
SQLite: An Embeddable SQL Database Engine
|
||||
|
||||
To compile the project, first create a directory in which to place
|
||||
the build products. It is recommended, but not required, that the
|
||||
build directory be separate from the source directory. Cd into the
|
||||
build directory and then from the build directory run the configure
|
||||
script found at the root of the source tree. Then run "make".
|
||||
|
||||
For example:
|
||||
|
||||
tar xzf sqlite.tar.gz ;# Unpack the source tree into "sqlite"
|
||||
mkdir bld ;# Build will occur in a sibling directory
|
||||
cd bld ;# Change to the build directory
|
||||
../sqlite/configure ;# Run the configure script
|
||||
make ;# Run the makefile.
|
||||
|
||||
The configure script uses autoconf 2.50 and libtool. If the configure
|
||||
script does not work out for you, there is a generic makefile named
|
||||
"Makefile.linux-gcc" in the top directory of the source tree that you
|
||||
can copy and edit to suite your needs. Comments on the generic makefile
|
||||
show what changes are needed.
|
||||
|
||||
The linux binaries on the website are created using the generic makefile,
|
||||
not the configure script. The configure script is unmaintained. (You
|
||||
can volunteer to take over maintenance of the configure script, if you want!)
|
||||
The windows binaries on the website are created using MinGW32 configured
|
||||
as a cross-compiler running under Linux. For details, see the ./publish.sh
|
||||
script at the top-level of the source tree.
|
||||
|
||||
Contacts:
|
||||
|
||||
http://www.sqlite.org/
|
||||
http://www.hwaci.com/sw/sqlite/
|
||||
http://groups.yahoo.com/group/sqlite/
|
||||
drh@hwaci.com
|
||||
@@ -1,8 +0,0 @@
|
||||
#include "config.w32.h"
|
||||
#if ZTS
|
||||
# define THREADSAFE 1
|
||||
#endif
|
||||
#if !ZEND_DEBUG && !defined(NDEBUG)
|
||||
# define NDEBUG
|
||||
#endif
|
||||
#define SQLITE_PTR_SZ 4
|
||||
@@ -1,33 +0,0 @@
|
||||
<?php
|
||||
if (!extension_loaded("sqlite")) {
|
||||
dl("sqlite.so");
|
||||
}
|
||||
|
||||
debug_zval_dump(sqlite_libversion());
|
||||
debug_zval_dump(sqlite_libencoding());
|
||||
|
||||
$s = sqlite_open("weztest.sqlite", 0666, $err);
|
||||
|
||||
debug_zval_dump($err);
|
||||
debug_zval_dump($s);
|
||||
|
||||
$r = sqlite_query("create table foo (a INTEGER PRIMARY KEY, b INTEGER )", $s);
|
||||
debug_zval_dump(sqlite_last_error($s));
|
||||
debug_zval_dump(sqlite_error_string(sqlite_last_error($s)));
|
||||
|
||||
$r = sqlite_query("select *, php('md5', sql) as o from sqlite_master", $s);
|
||||
debug_zval_dump($r);
|
||||
debug_zval_dump(sqlite_num_rows($r));
|
||||
debug_zval_dump(sqlite_num_fields($r));
|
||||
|
||||
for ($j = 0; $j < sqlite_num_fields($r); $j++) {
|
||||
echo "Field $j is " . sqlite_field_name($r, $j) . "\n";
|
||||
}
|
||||
|
||||
while ($row = sqlite_fetch_array($r, SQLITE_ASSOC)) {
|
||||
print_r($row);
|
||||
}
|
||||
|
||||
sqlite_close($s);
|
||||
|
||||
?>
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php #vim:ft=php
|
||||
$dbname = tempnam(dirname(__FILE__), "phpsql");
|
||||
function cleanup() {
|
||||
if ($GLOBALS['db']) {
|
||||
sqlite_close($GLOBALS['db']);
|
||||
}
|
||||
unlink($GLOBALS['dbname']);
|
||||
}
|
||||
register_shutdown_function("cleanup");
|
||||
$db = sqlite_open($dbname);
|
||||
?>
|
||||
@@ -1,17 +0,0 @@
|
||||
--TEST--
|
||||
sqlite: sqlite_open/close
|
||||
--INI--
|
||||
sqlite.assoc_case=0
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("sqlite")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once('blankdb.inc');
|
||||
echo "$db\n";
|
||||
sqlite_close($db);
|
||||
$db = NULL;
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
Resource id #%d
|
||||
Done
|
||||
@@ -1,31 +0,0 @@
|
||||
--TEST--
|
||||
sqlite: Simple insert/select
|
||||
--INI--
|
||||
sqlite.assoc_case=0
|
||||
--SKIPIF--
|
||||
<?php # vim:ft=php
|
||||
if (!extension_loaded("sqlite")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
include "blankdb.inc";
|
||||
|
||||
sqlite_query("CREATE TABLE foo(c1 date, c2 time, c3 varchar(64))", $db);
|
||||
sqlite_query("INSERT INTO foo VALUES ('2002-01-02', '12:49:00', NULL)", $db);
|
||||
$r = sqlite_query("SELECT * from foo", $db);
|
||||
var_dump(sqlite_fetch_array($r));
|
||||
?>
|
||||
--EXPECT--
|
||||
array(6) {
|
||||
[0]=>
|
||||
string(10) "2002-01-02"
|
||||
["c1"]=>
|
||||
string(10) "2002-01-02"
|
||||
[1]=>
|
||||
string(8) "12:49:00"
|
||||
["c2"]=>
|
||||
string(8) "12:49:00"
|
||||
[2]=>
|
||||
NULL
|
||||
["c3"]=>
|
||||
NULL
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
--TEST--
|
||||
sqlite: Simple insert/select, different result represenatation
|
||||
--INI--
|
||||
sqlite.assoc_case=0
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("sqlite")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
include "blankdb.inc";
|
||||
|
||||
sqlite_query("CREATE TABLE foo(c1 date, c2 time, c3 varchar(64))", $db);
|
||||
sqlite_query("INSERT INTO foo VALUES ('2002-01-02', '12:49:00', NULL)", $db);
|
||||
$r = sqlite_query("SELECT * from foo", $db);
|
||||
var_dump(sqlite_fetch_array($r, SQLITE_BOTH));
|
||||
$r = sqlite_query("SELECT * from foo", $db);
|
||||
var_dump(sqlite_fetch_array($r, SQLITE_NUM));
|
||||
$r = sqlite_query("SELECT * from foo", $db);
|
||||
var_dump(sqlite_fetch_array($r, SQLITE_ASSOC));
|
||||
?>
|
||||
--EXPECT--
|
||||
array(6) {
|
||||
[0]=>
|
||||
string(10) "2002-01-02"
|
||||
["c1"]=>
|
||||
string(10) "2002-01-02"
|
||||
[1]=>
|
||||
string(8) "12:49:00"
|
||||
["c2"]=>
|
||||
string(8) "12:49:00"
|
||||
[2]=>
|
||||
NULL
|
||||
["c3"]=>
|
||||
NULL
|
||||
}
|
||||
array(3) {
|
||||
[0]=>
|
||||
string(10) "2002-01-02"
|
||||
[1]=>
|
||||
string(8) "12:49:00"
|
||||
[2]=>
|
||||
NULL
|
||||
}
|
||||
array(3) {
|
||||
["c1"]=>
|
||||
string(10) "2002-01-02"
|
||||
["c2"]=>
|
||||
string(8) "12:49:00"
|
||||
["c3"]=>
|
||||
NULL
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
--TEST--
|
||||
sqlite: binary encoding
|
||||
--INI--
|
||||
sqlite.assoc_case=0
|
||||
--SKIPIF--
|
||||
<?php # vim:ft=php
|
||||
if (!extension_loaded("sqlite")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
include "blankdb.inc";
|
||||
|
||||
$strings = array(
|
||||
"hello",
|
||||
"hello\x01o",
|
||||
"\x01hello there",
|
||||
"hello\x00there",
|
||||
""
|
||||
);
|
||||
|
||||
sqlite_query("CREATE TABLE strings(a)", $db);
|
||||
|
||||
foreach ($strings as $str) {
|
||||
sqlite_query("INSERT INTO strings VALUES('" . sqlite_escape_string($str) . "')", $db);
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
$r = sqlite_query("SELECT * from strings", $db);
|
||||
while ($row = sqlite_fetch_array($r, SQLITE_NUM)) {
|
||||
if ($row[0] !== $strings[$i]) {
|
||||
echo "FAIL!\n";
|
||||
var_dump($row[0]);
|
||||
var_dump($strings[$i]);
|
||||
} else {
|
||||
echo "OK!\n";
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
echo "DONE!\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
OK!
|
||||
OK!
|
||||
OK!
|
||||
OK!
|
||||
OK!
|
||||
DONE!
|
||||
@@ -1,47 +0,0 @@
|
||||
--TEST--
|
||||
sqlite: aggregate functions
|
||||
--INI--
|
||||
sqlite.assoc_case=0
|
||||
--SKIPIF--
|
||||
<?php # vim:ft=php
|
||||
if (!extension_loaded("sqlite")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
include "blankdb.inc";
|
||||
|
||||
$data = array(
|
||||
"one",
|
||||
"two",
|
||||
"three"
|
||||
);
|
||||
|
||||
sqlite_query("CREATE TABLE strings(a)", $db);
|
||||
|
||||
foreach ($data as $str) {
|
||||
sqlite_query("INSERT INTO strings VALUES('" . sqlite_escape_string($str) . "')", $db);
|
||||
}
|
||||
|
||||
function cat_step(&$context, $string)
|
||||
{
|
||||
$context .= $string;
|
||||
}
|
||||
|
||||
function cat_fin(&$context)
|
||||
{
|
||||
return $context;
|
||||
}
|
||||
|
||||
sqlite_create_aggregate($db, "cat", "cat_step", "cat_fin");
|
||||
|
||||
$r = sqlite_query("SELECT cat(a) from strings", $db);
|
||||
while ($row = sqlite_fetch_array($r, SQLITE_NUM)) {
|
||||
var_dump($row);
|
||||
}
|
||||
echo "DONE!\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(11) "onetwothree"
|
||||
}
|
||||
DONE!
|
||||
@@ -1,52 +0,0 @@
|
||||
--TEST--
|
||||
sqlite: regular functions
|
||||
--INI--
|
||||
sqlite.assoc_case=0
|
||||
--SKIPIF--
|
||||
<?php # vim:ft=php
|
||||
if (!extension_loaded("sqlite")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
include "blankdb.inc";
|
||||
|
||||
$data = array(
|
||||
array("one", "uno"),
|
||||
array("two", "dos"),
|
||||
array("three", "tres"),
|
||||
);
|
||||
|
||||
sqlite_query("CREATE TABLE strings(a,b)", $db);
|
||||
|
||||
function implode_args()
|
||||
{
|
||||
$args = func_get_args();
|
||||
$sep = array_shift($args);
|
||||
return implode($sep, $args);
|
||||
}
|
||||
|
||||
foreach ($data as $row) {
|
||||
sqlite_query("INSERT INTO strings VALUES('" . sqlite_escape_string($row[0]) . "','" . sqlite_escape_string($row[1]) . "')", $db);
|
||||
}
|
||||
|
||||
sqlite_create_function($db, "implode", "implode_args");
|
||||
|
||||
$r = sqlite_query("SELECT implode('-', a, b) from strings", $db);
|
||||
while ($row = sqlite_fetch_array($r, SQLITE_NUM)) {
|
||||
var_dump($row);
|
||||
}
|
||||
echo "DONE!\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(7) "one-uno"
|
||||
}
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(7) "two-dos"
|
||||
}
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(10) "three-tres"
|
||||
}
|
||||
DONE!
|
||||
@@ -1,51 +0,0 @@
|
||||
--TEST--
|
||||
sqlite: Simple insert/select (unbuffered)
|
||||
--INI--
|
||||
sqlite.assoc_case=0
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("sqlite")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
include "blankdb.inc";
|
||||
|
||||
sqlite_query("CREATE TABLE foo(c1 date, c2 time, c3 varchar(64))", $db);
|
||||
sqlite_query("INSERT INTO foo VALUES ('2002-01-02', '12:49:00', NULL)", $db);
|
||||
$r = sqlite_unbuffered_query("SELECT * from foo", $db);
|
||||
var_dump(sqlite_fetch_array($r, SQLITE_BOTH));
|
||||
$r = sqlite_unbuffered_query("SELECT * from foo", $db);
|
||||
var_dump(sqlite_fetch_array($r, SQLITE_NUM));
|
||||
$r = sqlite_unbuffered_query("SELECT * from foo", $db);
|
||||
var_dump(sqlite_fetch_array($r, SQLITE_ASSOC));
|
||||
?>
|
||||
--EXPECT--
|
||||
array(6) {
|
||||
[0]=>
|
||||
string(10) "2002-01-02"
|
||||
["c1"]=>
|
||||
string(10) "2002-01-02"
|
||||
[1]=>
|
||||
string(8) "12:49:00"
|
||||
["c2"]=>
|
||||
string(8) "12:49:00"
|
||||
[2]=>
|
||||
NULL
|
||||
["c3"]=>
|
||||
NULL
|
||||
}
|
||||
array(3) {
|
||||
[0]=>
|
||||
string(10) "2002-01-02"
|
||||
[1]=>
|
||||
string(8) "12:49:00"
|
||||
[2]=>
|
||||
NULL
|
||||
}
|
||||
array(3) {
|
||||
["c1"]=>
|
||||
string(10) "2002-01-02"
|
||||
["c2"]=>
|
||||
string(8) "12:49:00"
|
||||
["c3"]=>
|
||||
NULL
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
--TEST--
|
||||
sqlite: fetch all (buffered)
|
||||
--INI--
|
||||
sqlite.assoc_case=0
|
||||
--SKIPIF--
|
||||
<?php # vim:ft=php
|
||||
if (!extension_loaded("sqlite")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
include "blankdb.inc";
|
||||
|
||||
$data = array(
|
||||
"one",
|
||||
"two",
|
||||
"three"
|
||||
);
|
||||
|
||||
sqlite_query("CREATE TABLE strings(a VARCHAR)", $db);
|
||||
|
||||
foreach ($data as $str) {
|
||||
sqlite_query("INSERT INTO strings VALUES('$str')", $db);
|
||||
}
|
||||
|
||||
$r = sqlite_query("SELECT a from strings", $db);
|
||||
while ($row = sqlite_fetch_array($r, SQLITE_NUM)) {
|
||||
var_dump($row);
|
||||
}
|
||||
echo "DONE!\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(3) "one"
|
||||
}
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(3) "two"
|
||||
}
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(5) "three"
|
||||
}
|
||||
DONE!
|
||||
@@ -1,43 +0,0 @@
|
||||
--TEST--
|
||||
sqlite: fetch all (unbuffered)
|
||||
--INI--
|
||||
sqlite.assoc_case=0
|
||||
--SKIPIF--
|
||||
<?php # vim:ft=php
|
||||
if (!extension_loaded("sqlite")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
include "blankdb.inc";
|
||||
|
||||
$data = array(
|
||||
"one",
|
||||
"two",
|
||||
"three"
|
||||
);
|
||||
|
||||
sqlite_query("CREATE TABLE strings(a VARCHAR)", $db);
|
||||
|
||||
foreach ($data as $str) {
|
||||
sqlite_query("INSERT INTO strings VALUES('$str')", $db);
|
||||
}
|
||||
|
||||
$r = sqlite_unbuffered_query("SELECT a from strings", $db);
|
||||
while ($row = sqlite_fetch_array($r, SQLITE_NUM)) {
|
||||
var_dump($row);
|
||||
}
|
||||
echo "DONE!\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(3) "one"
|
||||
}
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(3) "two"
|
||||
}
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(5) "three"
|
||||
}
|
||||
DONE!
|
||||
@@ -1,78 +0,0 @@
|
||||
--TEST--
|
||||
sqlite: fetch all (iterator)
|
||||
--INI--
|
||||
sqlite.assoc_case=0
|
||||
--SKIPIF--
|
||||
<?php # vim:ft=php
|
||||
if (!extension_loaded("sqlite")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
include "blankdb.inc";
|
||||
|
||||
$data = array(
|
||||
"one",
|
||||
"two",
|
||||
"three"
|
||||
);
|
||||
|
||||
sqlite_query("CREATE TABLE strings(a VARCHAR)", $db);
|
||||
|
||||
foreach ($data as $str) {
|
||||
sqlite_query("INSERT INTO strings VALUES('$str')", $db);
|
||||
}
|
||||
|
||||
$r = sqlite_unbuffered_query("SELECT a from strings", $db);
|
||||
while (sqlite_has_more($r)) {
|
||||
var_dump(sqlite_current($r, SQLITE_NUM));
|
||||
sqlite_next($r);
|
||||
}
|
||||
$r = sqlite_query("SELECT a from strings", $db);
|
||||
while (sqlite_has_more($r)) {
|
||||
var_dump(sqlite_current($r, SQLITE_NUM));
|
||||
sqlite_next($r);
|
||||
}
|
||||
sqlite_rewind($r);
|
||||
while (sqlite_has_more($r)) {
|
||||
var_dump(sqlite_current($r, SQLITE_NUM));
|
||||
sqlite_next($r);
|
||||
}
|
||||
echo "DONE!\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(3) "one"
|
||||
}
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(3) "two"
|
||||
}
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(5) "three"
|
||||
}
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(3) "one"
|
||||
}
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(3) "two"
|
||||
}
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(5) "three"
|
||||
}
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(3) "one"
|
||||
}
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(3) "two"
|
||||
}
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(5) "three"
|
||||
}
|
||||
DONE!
|
||||
@@ -1,27 +0,0 @@
|
||||
--TEST--
|
||||
sqlite: returned associative column names
|
||||
--INI--
|
||||
sqlite.assoc_case=0
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("sqlite")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
include "blankdb.inc";
|
||||
|
||||
sqlite_query("CREATE TABLE foo (c1 char, c2 char, c3 char)", $db);
|
||||
sqlite_query("CREATE TABLE bar (c1 char, c2 char, c3 char)", $db);
|
||||
sqlite_query("INSERT INTO foo VALUES ('1', '2', '3')", $db);
|
||||
sqlite_query("INSERT INTO bar VALUES ('4', '5', '6')", $db);
|
||||
$r = sqlite_query("SELECT * from foo, bar", $db, SQLITE_ASSOC);
|
||||
var_dump(sqlite_fetch_array($r));
|
||||
?>
|
||||
--EXPECT--
|
||||
array(3) {
|
||||
["c1"]=>
|
||||
string(1) "4"
|
||||
["c2"]=>
|
||||
string(1) "5"
|
||||
["c3"]=>
|
||||
string(1) "6"
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
--TEST--
|
||||
sqlite: read field names
|
||||
--INI--
|
||||
sqlite.assoc_case=0
|
||||
--SKIPIF--
|
||||
<?php # vim:ft=php
|
||||
if (!extension_loaded("sqlite")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
include "blankdb.inc";
|
||||
|
||||
sqlite_query("CREATE TABLE strings(foo VARCHAR, bar VARCHAR, baz VARCHAR)", $db);
|
||||
|
||||
echo "Buffered\n";
|
||||
$r = sqlite_query("SELECT * from strings", $db);
|
||||
for($i=0; $i<sqlite_num_fields($r); $i++) {
|
||||
var_dump(sqlite_field_name($r, $i));
|
||||
}
|
||||
echo "Unbuffered\n";
|
||||
$r = sqlite_unbuffered_query("SELECT * from strings", $db);
|
||||
for($i=0; $i<sqlite_num_fields($r); $i++) {
|
||||
var_dump(sqlite_field_name($r, $i));
|
||||
}
|
||||
echo "DONE!\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
Buffered
|
||||
string(3) "foo"
|
||||
string(3) "bar"
|
||||
string(3) "baz"
|
||||
Unbuffered
|
||||
string(3) "foo"
|
||||
string(3) "bar"
|
||||
string(3) "baz"
|
||||
DONE!
|
||||
@@ -6,8 +6,8 @@ Bug #22414: passthru() does not read data correctly
|
||||
die('skip this test cannot be run under safe-mode');
|
||||
}
|
||||
?>
|
||||
--POST--
|
||||
--GET--
|
||||
--INI--
|
||||
output_handler=
|
||||
--FILE--
|
||||
<?php
|
||||
$php = getenv('TEST_PHP_EXECUTABLE');
|
||||
|
||||
Reference in new issue
Block a user