PHP  
 PHP: Test and Code Coverage Analysis
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

LCOV - code coverage report
Current view: top level - ext/oci8 - oci8_interface.c (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 850 995 85.4 %
Date: 2014-07-13 Functions: 75 75 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :    +----------------------------------------------------------------------+
       3             :    | PHP Version 5                                                        |
       4             :    +----------------------------------------------------------------------+
       5             :    | Copyright (c) 1997-2013 The PHP Group                                |
       6             :    +----------------------------------------------------------------------+
       7             :    | This source file is subject to version 3.01 of the PHP license,      |
       8             :    | that is bundled with this package in the file LICENSE, and is        |
       9             :    | available through the world-wide-web at the following url:           |
      10             :    | http://www.php.net/license/3_01.txt                                  |
      11             :    | If you did not receive a copy of the PHP license and are unable to   |
      12             :    | obtain it through the world-wide-web, please send a note to          |
      13             :    | license@php.net so we can mail you a copy immediately.               |
      14             :    +----------------------------------------------------------------------+
      15             :    | Authors: Stig Sæther Bakken <ssb@php.net>                            |
      16             :    |          Thies C. Arntzen <thies@thieso.net>                         |
      17             :    |                                                                      |
      18             :    | Collection support by Andy Sautins <asautins@veripost.net>           |
      19             :    | Temporary LOB support by David Benson <dbenson@mancala.com>          |
      20             :    | ZTS per process OCIPLogon by Harald Radi <harald.radi@nme.at>        |
      21             :    |                                                                      |
      22             :    | Redesigned by: Antony Dovgal <antony@zend.com>                       |
      23             :    |                Andi Gutmans <andi@zend.com>                          |
      24             :    |                Wez Furlong <wez@omniti.com>                          |
      25             :    +----------------------------------------------------------------------+
      26             : */
      27             : 
      28             : /* $Id$ */
      29             : 
      30             : #ifdef HAVE_CONFIG_H
      31             : #include "config.h"
      32             : #endif
      33             : 
      34             : #include "php.h"
      35             : #include "ext/standard/info.h"
      36             : #include "php_ini.h"
      37             : 
      38             : #if HAVE_OCI8
      39             : 
      40             : #include "php_oci8.h"
      41             : #include "php_oci8_int.h"
      42             : 
      43             : #ifndef OCI_STMT_CALL
      44             : #define OCI_STMT_CALL 10
      45             : #endif
      46             : 
      47             : /* {{{ proto bool oci_define_by_name(resource stmt, string name, mixed &var [, int type])
      48             :    Define a PHP variable to an Oracle column by name */
      49             : /* if you want to define a LOB/CLOB etc make sure you allocate it via OCINewDescriptor BEFORE defining!!! */
      50       30057 : PHP_FUNCTION(oci_define_by_name)
      51             : {
      52             :         zval *stmt, *var;
      53             :         char *name;
      54             :         int name_len;
      55       30057 :         long type = 0;
      56             :         php_oci_statement *statement;
      57             :         php_oci_define *define, *tmp_define;
      58             : 
      59       30057 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsz/|l", &stmt, &name, &name_len, &var, &type) == FAILURE) {
      60           2 :                 return;
      61             :         }
      62             : 
      63       30055 :         if (!name_len) {
      64           1 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Column name cannot be empty");
      65           1 :                 RETURN_FALSE;
      66             :         }
      67             : 
      68       30054 :         PHP_OCI_ZVAL_TO_STATEMENT(stmt, statement);
      69             : 
      70       30054 :         if (statement->defines == NULL) {
      71       15037 :                 ALLOC_HASHTABLE(statement->defines);
      72       15037 :                 zend_hash_init(statement->defines, 13, NULL, php_oci_define_hash_dtor, 0);
      73             :         }
      74             : 
      75       30054 :         define = ecalloc(1,sizeof(php_oci_define));
      76             : 
      77       30054 :         if (zend_hash_add(statement->defines, name, name_len, define, sizeof(php_oci_define), (void **)&tmp_define) == SUCCESS) {
      78       30053 :                 efree(define);
      79       30053 :                 define = tmp_define;
      80             :         } else {
      81           1 :                 efree(define);
      82           1 :                 RETURN_FALSE;
      83             :         }
      84             : 
      85       30053 :         define->name = (text*) estrndup(name, name_len);
      86       30053 :         define->name_len = name_len;
      87       30053 :         define->type = type;
      88       30053 :         define->zval = var;
      89       30053 :         zval_add_ref(&var);
      90             : 
      91       30053 :         RETURN_TRUE;
      92             : }
      93             : /* }}} */
      94             : 
      95             : /* {{{ proto bool oci_bind_by_name(resource stmt, string name, mixed &var, [, int maxlength [, int type]])
      96             :    Bind a PHP variable to an Oracle placeholder by name */
      97             : /* if you want to bind a LOB/CLOB etc make sure you allocate it via OCINewDescriptor BEFORE binding!!! */
      98        4071 : PHP_FUNCTION(oci_bind_by_name)
      99             : {
     100        4071 :         ub2     bind_type = SQLT_CHR; /* unterminated string */
     101             :         int name_len;
     102        4071 :         long maxlen = -1, type = 0;
     103             :         char *name;
     104             :         zval *z_statement;
     105        4071 :         zval *bind_var = NULL;
     106             :         php_oci_statement *statement;
     107             :         
     108        4071 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsz/|ll", &z_statement, &name, &name_len, &bind_var, &maxlen, &type) == FAILURE) {
     109           5 :                 return;
     110             :         }
     111             : 
     112        4066 :         if (type) {
     113         330 :                 bind_type = (ub2) type;
     114             :         }
     115             :         
     116        4066 :         PHP_OCI_ZVAL_TO_STATEMENT(z_statement, statement);
     117             : 
     118        4066 :         if (php_oci_bind_by_name(statement, name, name_len, bind_var, maxlen, bind_type TSRMLS_CC)) {
     119          13 :                 RETURN_FALSE;
     120             :         }
     121        4053 :         RETURN_TRUE;
     122             : }
     123             : /* }}} */
     124             : 
     125             : /* {{{ proto bool oci_bind_array_by_name(resource stmt, string name, array &var, int max_table_length [, int max_item_length [, int type ]])
     126             :    Bind a PHP array to an Oracle PL/SQL type by name */
     127          35 : PHP_FUNCTION(oci_bind_array_by_name)
     128             : {
     129             :         int name_len;
     130          35 :         long max_item_len = -1;
     131          35 :         long max_array_len = 0;
     132          35 :         long type = SQLT_AFC;
     133             :         char *name;
     134             :         zval *z_statement;
     135          35 :         zval *bind_var = NULL;
     136             :         php_oci_statement *statement;
     137             :         
     138          35 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsz/l|ll", &z_statement, &name, &name_len, &bind_var, &max_array_len, &max_item_len, &type) == FAILURE) {
     139           1 :                 return;
     140             :         }
     141             : 
     142          34 :         PHP_OCI_ZVAL_TO_STATEMENT(z_statement, statement);
     143             : 
     144          33 :         if (ZEND_NUM_ARGS() == 5 && max_item_len <= 0) {
     145           3 :                 max_item_len = -1;
     146             :         }
     147             :         
     148          33 :         if (max_array_len <= 0) {
     149           1 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Maximum array length must be greater than zero");
     150           1 :                 RETURN_FALSE;
     151             :         }
     152             :         
     153          32 :         if (php_oci_bind_array_by_name(statement, name, name_len, bind_var, max_array_len, max_item_len, type TSRMLS_CC)) {
     154          11 :                 RETURN_FALSE;
     155             :         }
     156          21 :         RETURN_TRUE;
     157             : }
     158             : /* }}} */
     159             : 
     160             : /* {{{ proto bool oci_free_descriptor()
     161             :    Deletes large object description */
     162      181112 : PHP_FUNCTION(oci_free_descriptor)
     163             : {
     164      181112 :         zval **tmp, *z_descriptor = getThis();
     165             :         php_oci_descriptor *descriptor;
     166             : 
     167      181112 :         if (!getThis()) {
     168           8 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &z_descriptor, oci_lob_class_entry_ptr) == FAILURE) {
     169           3 :                         return;
     170             :                 }
     171             :         }
     172             :         
     173      181109 :         if (zend_hash_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor"), (void **)&tmp) == FAILURE) {
     174           1 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find descriptor property");
     175           1 :                 RETURN_FALSE;
     176             :         }
     177             : 
     178      181108 :         PHP_OCI_ZVAL_TO_DESCRIPTOR(*tmp, descriptor);
     179             : 
     180      181107 :         zend_list_delete(descriptor->id);
     181      181107 :         RETURN_TRUE;
     182             : }
     183             : /* }}} */
     184             : 
     185             : /* {{{ proto bool oci_lob_save( string data [, int offset ])
     186             :    Saves a large object */
     187          29 : PHP_FUNCTION(oci_lob_save)
     188             : {
     189          29 :         zval **tmp, *z_descriptor = getThis();
     190             :         php_oci_descriptor *descriptor;
     191             :         char *data;
     192             :         int data_len;
     193          29 :         long offset = 0;
     194             :         ub4 bytes_written;
     195             : 
     196          29 :         if (getThis()) {
     197          24 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &data, &data_len, &offset) == FAILURE) {
     198           1 :                         return;
     199             :                 }
     200             :         }
     201             :         else {
     202           5 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Os|l", &z_descriptor, oci_lob_class_entry_ptr, &data, &data_len, &offset) == FAILURE) {
     203           3 :                         return;
     204             :                 }
     205             :         }
     206             :         
     207          25 :         if (zend_hash_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor"), (void **)&tmp) == FAILURE) {
     208           1 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find descriptor property");
     209           1 :                 RETURN_FALSE;
     210             :         }
     211             : 
     212          24 :         PHP_OCI_ZVAL_TO_DESCRIPTOR(*tmp, descriptor);
     213             : 
     214          24 :         if (offset < 0) {
     215           1 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset parameter must be greater than or equal to 0");
     216           1 :                 RETURN_FALSE;
     217             :         }
     218             :         
     219          23 :         if (php_oci_lob_write(descriptor, offset, data, data_len, &bytes_written TSRMLS_CC)) {
     220           1 :                 RETURN_FALSE;
     221             :         }
     222          22 :         RETURN_TRUE;
     223             : }
     224             : /* }}} */
     225             : 
     226             : /* {{{ proto bool oci_lob_import( string filename )
     227             :    Loads file into a LOB */
     228          13 : PHP_FUNCTION(oci_lob_import)
     229             : {
     230          13 :         zval **tmp, *z_descriptor = getThis();
     231             :         php_oci_descriptor *descriptor;
     232             :         char *filename;
     233             :         int filename_len;
     234             : 
     235          13 :         if (getThis()) {
     236             : #if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3) || (PHP_MAJOR_VERSION > 5)
     237             :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &filename, &filename_len) == FAILURE) {
     238             : #else
     239           7 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == FAILURE) {
     240             : #endif
     241           1 :                         return;
     242             :                 }
     243             :         }
     244             :         else {
     245             : #if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3) || (PHP_MAJOR_VERSION > 5)
     246             :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Op", &z_descriptor, oci_lob_class_entry_ptr, &filename, &filename_len) == FAILURE) {
     247             : #else
     248           6 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Os", &z_descriptor, oci_lob_class_entry_ptr, &filename, &filename_len) == FAILURE) {
     249             : #endif
     250           4 :                         return;
     251             :                 }       
     252             :         }
     253             : 
     254             : #if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 4) || (PHP_MAJOR_VERSION < 5)
     255             :         /* The "p" parsing parameter handles this case in PHP 5.4+ */
     256           8 :         if (strlen(filename) != filename_len) {
     257           1 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Filename cannot contain null bytes");
     258           1 :                 RETURN_FALSE;  
     259             :         }
     260             : #endif
     261             : 
     262           7 :         if (zend_hash_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor"), (void **)&tmp) == FAILURE) {
     263           1 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find descriptor property");
     264           1 :                 RETURN_FALSE;
     265             :         }
     266             : 
     267           6 :         PHP_OCI_ZVAL_TO_DESCRIPTOR(*tmp, descriptor);
     268             : 
     269           6 :         if (php_oci_lob_import(descriptor, filename TSRMLS_CC)) {
     270           2 :                 RETURN_FALSE;
     271             :         }
     272           4 :         RETURN_TRUE;
     273             : }
     274             : /* }}} */
     275             : 
     276             : /* {{{ proto string oci_lob_load()
     277             :    Loads a large object */
     278          77 : PHP_FUNCTION(oci_lob_load)
     279             : {
     280          77 :         zval **tmp, *z_descriptor = getThis();
     281             :         php_oci_descriptor *descriptor;
     282          77 :         char *buffer = NULL;
     283             :         ub4 buffer_len;
     284             : 
     285          77 :         if (!getThis()) {
     286           5 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &z_descriptor, oci_lob_class_entry_ptr) == FAILURE) {
     287           3 :                         return;
     288             :                 }       
     289             :         }
     290             :         
     291          74 :         if (zend_hash_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor"), (void **)&tmp) == FAILURE) {
     292           1 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find descriptor property");
     293           1 :                 RETURN_FALSE;
     294             :         }
     295             :         
     296          73 :         PHP_OCI_ZVAL_TO_DESCRIPTOR(*tmp, descriptor);
     297             : 
     298          73 :         if (php_oci_lob_read(descriptor, -1, 0, &buffer, &buffer_len TSRMLS_CC)) {
     299           0 :                 RETURN_FALSE;
     300             :         }
     301          73 :         if (buffer_len > 0) {
     302          59 :                 RETURN_STRINGL(buffer, buffer_len, 0);
     303             :         }
     304             :         else {
     305          14 :                 RETURN_EMPTY_STRING();
     306             :         }
     307             : }
     308             : /* }}} */
     309             : 
     310             : /* {{{ proto string oci_lob_read( int length )
     311             :    Reads particular part of a large object */
     312         448 : PHP_FUNCTION(oci_lob_read)
     313             : {
     314         448 :         zval **tmp, *z_descriptor = getThis();
     315             :         php_oci_descriptor *descriptor;
     316             :         long length;
     317             :         char *buffer;
     318             :         ub4 buffer_len;
     319             : 
     320         448 :         if (getThis()) {
     321         440 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &length) == FAILURE) {
     322           0 :                         return;
     323             :                 }
     324             :         }
     325             :         else {
     326           8 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Ol", &z_descriptor, oci_lob_class_entry_ptr, &length) == FAILURE) {
     327           4 :                         return;
     328             :                 }       
     329             :         }
     330             : 
     331         444 :         if (zend_hash_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor"), (void **)&tmp) == FAILURE) {
     332           1 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find descriptor property");
     333           1 :                 RETURN_FALSE;
     334             :         }
     335             :         
     336         443 :         PHP_OCI_ZVAL_TO_DESCRIPTOR(*tmp, descriptor);
     337             : 
     338         443 :         if (length <= 0) {
     339           1 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length parameter must be greater than 0");
     340           1 :                 RETURN_FALSE;
     341             :         }
     342             :         
     343         442 :         if (php_oci_lob_read(descriptor, length, descriptor->lob_current_position, &buffer, &buffer_len TSRMLS_CC)) {
     344           1 :                 RETURN_FALSE;
     345             :         }       
     346         441 :         if (buffer_len > 0) {
     347         438 :                 RETURN_STRINGL(buffer, buffer_len, 0);
     348             :         }
     349             :         else {
     350           3 :                 RETURN_EMPTY_STRING();
     351             :         }
     352             : }
     353             : /* }}} */
     354             : 
     355             : /* {{{ proto bool oci_lob_eof()
     356             :    Checks if EOF is reached */
     357          18 : PHP_FUNCTION(oci_lob_eof)
     358             : {
     359          18 :         zval **tmp, *z_descriptor = getThis();
     360             :         php_oci_descriptor *descriptor;
     361             :         ub4 lob_length;
     362             :         
     363          18 :         if (!getThis()) {
     364           4 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &z_descriptor, oci_lob_class_entry_ptr) == FAILURE) {
     365           2 :                         return;
     366             :                 }       
     367             :         }
     368             :         
     369          16 :         if (zend_hash_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor"), (void **)&tmp) == FAILURE) {
     370           1 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find descriptor property");
     371           1 :                 RETURN_FALSE;
     372             :         }
     373             :         
     374          15 :         PHP_OCI_ZVAL_TO_DESCRIPTOR(*tmp, descriptor);
     375             :         
     376          15 :         if (!php_oci_lob_get_length(descriptor, &lob_length TSRMLS_CC) && lob_length >= 0) {
     377          15 :                 if (lob_length == descriptor->lob_current_position) {
     378           4 :                         RETURN_TRUE;
     379             :                 }
     380             :         }
     381          11 :         RETURN_FALSE;
     382             : }
     383             : /* }}} */
     384             : 
     385             : /* {{{ proto int oci_lob_tell()
     386             :    Tells LOB pointer position */
     387         420 : PHP_FUNCTION(oci_lob_tell)
     388             : {
     389         420 :         zval **tmp, *z_descriptor = getThis();
     390             :         php_oci_descriptor *descriptor;
     391             :         
     392         420 :         if (!getThis()) {
     393           1 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &z_descriptor, oci_lob_class_entry_ptr) == FAILURE) {
     394           1 :                         return;
     395             :                 }       
     396             :         }
     397             :         
     398         419 :         if (zend_hash_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor"), (void **)&tmp) == FAILURE) {
     399           0 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find descriptor property");
     400           0 :                 RETURN_FALSE;
     401             :         }
     402             :         
     403         419 :         PHP_OCI_ZVAL_TO_DESCRIPTOR(*tmp, descriptor);
     404             :         
     405         419 :         RETURN_LONG(descriptor->lob_current_position);       
     406             : }
     407             : /* }}} */
     408             : 
     409             : /* {{{ proto bool oci_lob_rewind()
     410             :    Rewind pointer of a LOB */
     411           4 : PHP_FUNCTION(oci_lob_rewind)
     412             : {
     413           4 :         zval **tmp, *z_descriptor = getThis();
     414             :         php_oci_descriptor *descriptor;
     415             :         
     416           4 :         if (!getThis()) {
     417           3 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &z_descriptor, oci_lob_class_entry_ptr) == FAILURE) {
     418           2 :                         return;
     419             :                 }       
     420             :         }
     421             :         
     422           2 :         if (zend_hash_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor"), (void **)&tmp) == FAILURE) {
     423           0 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find descriptor property");
     424           0 :                 RETURN_FALSE;
     425             :         }
     426             :         
     427           2 :         PHP_OCI_ZVAL_TO_DESCRIPTOR(*tmp, descriptor);
     428             :         
     429           2 :         descriptor->lob_current_position = 0;
     430             : 
     431           2 :         RETURN_TRUE;
     432             : }
     433             : /* }}} */
     434             : 
     435             : /* {{{ proto bool oci_lob_seek( int offset [, int whence ])
     436             :    Moves the pointer of a LOB */
     437          23 : PHP_FUNCTION(oci_lob_seek)
     438             : {
     439          23 :         zval **tmp, *z_descriptor = getThis();
     440             :         php_oci_descriptor *descriptor;
     441          23 :         long offset, whence = PHP_OCI_SEEK_SET;
     442             :         ub4 lob_length;
     443             :         
     444          23 :         if (getThis()) {
     445          20 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|l", &offset, &whence) == FAILURE) {
     446           1 :                         return;
     447             :                 }
     448             :         }
     449             :         else {
     450           3 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Ol|l", &z_descriptor, oci_lob_class_entry_ptr, &offset, &whence) == FAILURE) {
     451           2 :                         return;
     452             :                 }       
     453             :         }
     454             :         
     455          20 :         if (zend_hash_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor"), (void **)&tmp) == FAILURE) {
     456           0 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find descriptor property");
     457           0 :                 RETURN_FALSE;
     458             :         }
     459             :         
     460          20 :         PHP_OCI_ZVAL_TO_DESCRIPTOR(*tmp, descriptor);
     461             : 
     462          20 :         if (php_oci_lob_get_length(descriptor, &lob_length TSRMLS_CC)) {
     463           0 :                 RETURN_FALSE;
     464             :         }
     465             : 
     466          20 :         switch(whence) {
     467             :                 case PHP_OCI_SEEK_CUR:
     468           6 :                         descriptor->lob_current_position += offset;
     469           6 :                         break;
     470             :                 case PHP_OCI_SEEK_END:
     471           2 :                         if ((descriptor->lob_size + offset) >= 0) {
     472           2 :                                 descriptor->lob_current_position = descriptor->lob_size + offset;
     473             :                         }
     474             :                         else {
     475           0 :                                 descriptor->lob_current_position = 0;
     476             :                         }
     477           2 :                         break;
     478             :                 case PHP_OCI_SEEK_SET:
     479             :                 default:
     480          12 :                                 descriptor->lob_current_position = (offset > 0) ? offset : 0;
     481             :                         break;
     482             :         }       
     483          20 :         RETURN_TRUE;
     484             : }
     485             : /* }}} */
     486             : 
     487             : /* {{{ proto int oci_lob_size()
     488             :    Returns size of a large object */
     489         211 : PHP_FUNCTION(oci_lob_size)
     490             : {
     491         211 :         zval **tmp, *z_descriptor = getThis();
     492             :         php_oci_descriptor *descriptor;
     493             :         ub4 lob_length;
     494             :         
     495         211 :         if (!getThis()) {
     496           4 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &z_descriptor, oci_lob_class_entry_ptr) == FAILURE) {
     497           2 :                         return;
     498             :                 }       
     499             :         }
     500             :         
     501         209 :         if (zend_hash_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor"), (void **)&tmp) == FAILURE) {
     502           1 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find descriptor property");
     503           1 :                 RETURN_FALSE;
     504             :         }
     505             :         
     506         208 :         PHP_OCI_ZVAL_TO_DESCRIPTOR(*tmp, descriptor);
     507             :         
     508         208 :         if (php_oci_lob_get_length(descriptor, &lob_length TSRMLS_CC)) {
     509           0 :                 RETURN_FALSE;
     510             :         }
     511         208 :         RETURN_LONG(lob_length);
     512             : }
     513             : /* }}} */
     514             : 
     515             : /* {{{ proto int oci_lob_write( string string [, int length ])
     516             :    Writes data to current position of a LOB */
     517          57 : PHP_FUNCTION(oci_lob_write)
     518             : {
     519          57 :         zval **tmp, *z_descriptor = getThis();
     520             :         php_oci_descriptor *descriptor;
     521             :         int data_len;
     522          57 :         long write_len = 0;
     523             :         ub4 bytes_written;
     524             :         char *data;
     525             :         
     526          57 :         if (getThis()) {
     527          54 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &data, &data_len, &write_len) == FAILURE) {
     528           1 :                         return;
     529             :                 }
     530             :                 
     531          53 :                 if (ZEND_NUM_ARGS() == 2) {
     532           3 :                         data_len = MIN(data_len, write_len);
     533             :                 }
     534             :         }
     535             :         else {
     536           3 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Os|l", &z_descriptor, oci_lob_class_entry_ptr, &data, &data_len, &write_len) == FAILURE) {
     537           1 :                         return;
     538             :                 }
     539             : 
     540           2 :                 if (ZEND_NUM_ARGS() == 3) {
     541           0 :                         data_len = MIN(data_len, write_len);
     542             :                 }
     543             :         }
     544             :         
     545          55 :         if (zend_hash_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor"), (void **)&tmp) == FAILURE) {
     546           0 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find descriptor property");
     547           0 :                 RETURN_FALSE;
     548             :         }
     549             :         
     550          55 :         PHP_OCI_ZVAL_TO_DESCRIPTOR(*tmp, descriptor);
     551             :         
     552          53 :         if (data_len <= 0) {
     553           1 :                 RETURN_LONG(0);
     554             :         }
     555             :         
     556          52 :         if (php_oci_lob_write(descriptor, descriptor->lob_current_position, data, data_len, &bytes_written TSRMLS_CC)) {
     557           1 :                 RETURN_FALSE;
     558             :         }
     559          51 :         RETURN_LONG(bytes_written);
     560             : }
     561             : /* }}} */
     562             : 
     563             : /* {{{ proto bool oci_lob_append( object lob )
     564             :    Appends data from a LOB to another LOB */
     565           5 : PHP_FUNCTION(oci_lob_append)
     566             : {
     567           5 :         zval **tmp_dest, **tmp_from, *z_descriptor_dest = getThis(), *z_descriptor_from;
     568             :         php_oci_descriptor *descriptor_dest, *descriptor_from;
     569             :         
     570           5 :         if (getThis()) {
     571           1 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &z_descriptor_from, oci_lob_class_entry_ptr) == FAILURE) {
     572           0 :                         return;
     573             :                 }
     574             :         }
     575             :         else {
     576           4 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "OO", &z_descriptor_dest, oci_lob_class_entry_ptr, &z_descriptor_from, oci_lob_class_entry_ptr) == FAILURE) {
     577           3 :                         return;
     578             :                 }       
     579             :         }
     580             :         
     581           2 :         if (zend_hash_find(Z_OBJPROP_P(z_descriptor_dest), "descriptor", sizeof("descriptor"), (void **)&tmp_dest) == FAILURE) {
     582           0 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find descriptor property. The first argument should be valid descriptor object");
     583           0 :                 RETURN_FALSE;
     584             :         }
     585             :         
     586           2 :         if (zend_hash_find(Z_OBJPROP_P(z_descriptor_from), "descriptor", sizeof("descriptor"), (void **)&tmp_from) == FAILURE) {
     587           0 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find descriptor property. The second argument should be valid descriptor object");
     588           0 :                 RETURN_FALSE;
     589             :         }
     590             :         
     591           2 :         PHP_OCI_ZVAL_TO_DESCRIPTOR(*tmp_dest, descriptor_dest);
     592           2 :         PHP_OCI_ZVAL_TO_DESCRIPTOR(*tmp_from, descriptor_from);
     593             :         
     594           2 :         if (php_oci_lob_append(descriptor_dest, descriptor_from TSRMLS_CC)) {
     595           0 :                 RETURN_FALSE;
     596             :         }
     597             :         /* XXX should we increase lob_size here ? */
     598           2 :         RETURN_TRUE;
     599             : }
     600             : /* }}} */
     601             : 
     602             : /* {{{ proto bool oci_lob_truncate( [ int length ])
     603             :    Truncates a LOB */
     604          15 : PHP_FUNCTION(oci_lob_truncate)
     605             : {
     606          15 :         zval **tmp, *z_descriptor = getThis();
     607             :         php_oci_descriptor *descriptor;
     608          15 :         long trim_length = 0;
     609             :         ub4 ub_trim_length;
     610             :         
     611          15 :         if (getThis()) {
     612          14 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &trim_length) == FAILURE) {
     613           0 :                         return;
     614             :                 }
     615             :         }
     616             :         else {
     617           1 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|l", &z_descriptor, oci_lob_class_entry_ptr, &trim_length) == FAILURE) {
     618           1 :                         return;
     619             :                 }       
     620             :         }
     621             :         
     622          14 :         if (zend_hash_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor"), (void **)&tmp) == FAILURE) {
     623           0 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find descriptor property");
     624           0 :                 RETURN_FALSE;
     625             :         }
     626             : 
     627          14 :         if (trim_length < 0) {
     628           3 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length must be greater than or equal to zero");
     629           3 :                 RETURN_FALSE;
     630             :         }
     631             : 
     632          11 :         ub_trim_length = (ub4) trim_length;
     633          11 :         PHP_OCI_ZVAL_TO_DESCRIPTOR(*tmp, descriptor);
     634             :         
     635          11 :         if (php_oci_lob_truncate(descriptor, ub_trim_length TSRMLS_CC)) {
     636           1 :                 RETURN_FALSE;
     637             :         }
     638          10 :         RETURN_TRUE;
     639             : }
     640             : /* }}} */
     641             : 
     642             : /* {{{ proto int oci_lob_erase( [ int offset [, int length ] ] )
     643             :    Erases a specified portion of the internal LOB, starting at a specified offset */
     644          15 : PHP_FUNCTION(oci_lob_erase)
     645             : {
     646          15 :         zval **tmp, *z_descriptor = getThis();
     647             :         php_oci_descriptor *descriptor;
     648             :         ub4 bytes_erased;
     649          15 :         long offset = -1, length = -1;
     650             :         
     651          15 :         if (getThis()) {
     652           8 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ll", &offset, &length) == FAILURE) {
     653           1 :                         return;
     654             :                 }
     655             : 
     656           7 :                 if (ZEND_NUM_ARGS() > 0 && offset < 0) {
     657           2 :                         php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset must be greater than or equal to 0");
     658           2 :                         RETURN_FALSE;
     659             :                 }
     660             : 
     661           5 :                 if (ZEND_NUM_ARGS() > 1 && length < 0) {
     662           1 :                         php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length must be greater than or equal to 0");
     663           1 :                         RETURN_FALSE;
     664             :                 }
     665             :         }
     666             :         else {
     667           7 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|ll", &z_descriptor, oci_lob_class_entry_ptr, &offset, &length) == FAILURE) {
     668           2 :                         return;
     669             :                 }
     670             : 
     671           5 :                 if (ZEND_NUM_ARGS() > 1 && offset < 0) {
     672           2 :                         php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset must be greater than or equal to 0");
     673           2 :                         RETURN_FALSE;
     674             :                 }
     675             :                 
     676           3 :                 if (ZEND_NUM_ARGS() > 2 && length < 0) {
     677           1 :                         php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length must be greater than or equal to 0");
     678           1 :                         RETURN_FALSE;
     679             :                 }
     680             :         }
     681             : 
     682           6 :         if (zend_hash_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor"), (void **)&tmp) == FAILURE) {
     683           1 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find descriptor property");
     684           1 :                 RETURN_FALSE;
     685             :         }
     686             : 
     687           5 :         PHP_OCI_ZVAL_TO_DESCRIPTOR(*tmp, descriptor);
     688             : 
     689           5 :         if (php_oci_lob_erase(descriptor, offset, length, &bytes_erased TSRMLS_CC)) {
     690           2 :                 RETURN_FALSE;
     691             :         }
     692           3 :         RETURN_LONG(bytes_erased);
     693             : }
     694             : /* }}} */
     695             : 
     696             : /* {{{ proto bool oci_lob_flush( [ int flag ] )
     697             :    Flushes the LOB buffer */
     698           9 : PHP_FUNCTION(oci_lob_flush)
     699             : {
     700           9 :         zval **tmp, *z_descriptor = getThis();
     701             :         php_oci_descriptor *descriptor;
     702           9 :         long flush_flag = 0;
     703             :         
     704           9 :         if (getThis()) {
     705           8 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &flush_flag) == FAILURE) {
     706           0 :                         return;
     707             :                 }
     708             :         }
     709             :         else {
     710           1 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|l", &z_descriptor, oci_lob_class_entry_ptr, &flush_flag) == FAILURE) {
     711           1 :                         return;
     712             :                 }
     713             :         }
     714             :         
     715           8 :         if (zend_hash_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor"), (void **)&tmp) == FAILURE) {
     716           0 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find descriptor property");
     717           0 :                 RETURN_FALSE;
     718             :         }
     719             :         
     720           8 :         PHP_OCI_ZVAL_TO_DESCRIPTOR(*tmp, descriptor);
     721             :         
     722           8 :         if (descriptor->buffering == PHP_OCI_LOB_BUFFER_DISABLED) {
     723             :                 /* buffering wasn't enabled, there is nothing to flush */
     724           4 :                 RETURN_FALSE;
     725             :         }
     726             : 
     727           4 :         if (php_oci_lob_flush(descriptor, flush_flag TSRMLS_CC)) {
     728           1 :                 RETURN_FALSE;
     729             :         }
     730           3 :         RETURN_TRUE;
     731             : }
     732             : /* }}} */
     733             : 
     734             : /* {{{ proto bool ocisetbufferinglob( boolean flag )
     735             :    Enables/disables buffering for a LOB */
     736           7 : PHP_FUNCTION(ocisetbufferinglob)
     737             : {
     738           7 :         zval **tmp, *z_descriptor = getThis();
     739             :         php_oci_descriptor *descriptor;
     740             :         zend_bool flag;
     741             :         
     742           7 :         if (getThis()) {
     743           6 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &flag) == FAILURE) {
     744           0 :                         return;
     745             :                 }
     746             :         }
     747             :         else {
     748           1 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Ob", &z_descriptor, oci_lob_class_entry_ptr, &flag) == FAILURE) {
     749           1 :                         return;
     750             :                 }       
     751             :         }
     752             :         
     753           6 :         if (zend_hash_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor"), (void **)&tmp) == FAILURE) {
     754           0 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find descriptor property");
     755           0 :                 RETURN_FALSE;
     756             :         }
     757             :         
     758           6 :         PHP_OCI_ZVAL_TO_DESCRIPTOR(*tmp, descriptor);
     759             :         
     760           6 :         if (php_oci_lob_set_buffering(descriptor, flag TSRMLS_CC)) {
     761           0 :                 RETURN_FALSE;
     762             :         }
     763           6 :         RETURN_TRUE;
     764             : }
     765             : /* }}} */
     766             : 
     767             : /* {{{ proto bool ocigetbufferinglob()
     768             :    Returns current state of buffering for a LOB */
     769           4 : PHP_FUNCTION(ocigetbufferinglob)
     770             : {
     771           4 :         zval **tmp, *z_descriptor = getThis();
     772             :         php_oci_descriptor *descriptor;
     773             :         
     774           4 :         if (!getThis()) {
     775           1 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &z_descriptor, oci_lob_class_entry_ptr) == FAILURE) {
     776           1 :                         return;
     777             :                 }       
     778             :         }
     779             : 
     780           3 :         if (zend_hash_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor"), (void **)&tmp) == FAILURE) {
     781           0 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find descriptor property");
     782           0 :                 RETURN_FALSE;
     783             :         }
     784             :         
     785           3 :         PHP_OCI_ZVAL_TO_DESCRIPTOR(*tmp, descriptor);
     786             :         
     787           3 :         if (descriptor->buffering != PHP_OCI_LOB_BUFFER_DISABLED) {
     788           1 :                 RETURN_TRUE;
     789             :         }
     790           2 :         RETURN_FALSE;
     791             : }
     792             : /* }}} */
     793             : 
     794             : /* {{{ proto bool oci_lob_copy( object lob_to, object lob_from [, int length ] )
     795             :    Copies data from a LOB to another LOB */
     796           6 : PHP_FUNCTION(oci_lob_copy)
     797             : {
     798             :         zval **tmp_dest, **tmp_from, *z_descriptor_dest, *z_descriptor_from;
     799             :         php_oci_descriptor *descriptor_dest, *descriptor_from;
     800           6 :         long length = 0;
     801             :         
     802           6 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "OO|l", &z_descriptor_dest, oci_lob_class_entry_ptr, &z_descriptor_from, oci_lob_class_entry_ptr, &length) == FAILURE) {
     803           0 :                 return;
     804             :         }
     805             :         
     806           6 :         if (zend_hash_find(Z_OBJPROP_P(z_descriptor_dest), "descriptor", sizeof("descriptor"), (void **)&tmp_dest) == FAILURE) {
     807           0 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find descriptor property. The first argument should be valid descriptor object");
     808           0 :                 RETURN_FALSE;
     809             :         }
     810             :         
     811           6 :         if (zend_hash_find(Z_OBJPROP_P(z_descriptor_from), "descriptor", sizeof("descriptor"), (void **)&tmp_from) == FAILURE) {
     812           0 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find descriptor property. The second argument should be valid descriptor object");
     813           0 :                 RETURN_FALSE;
     814             :         }
     815             :         
     816           6 :         PHP_OCI_ZVAL_TO_DESCRIPTOR(*tmp_dest, descriptor_dest);
     817           6 :         PHP_OCI_ZVAL_TO_DESCRIPTOR(*tmp_from, descriptor_from);
     818             :         
     819           6 :         if (ZEND_NUM_ARGS() == 3 && length < 0) {
     820           1 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length parameter must be greater than 0");
     821           1 :                 RETURN_FALSE;
     822             :         }
     823             :         
     824           5 :         if (ZEND_NUM_ARGS() == 2) {
     825             :                 /* indicate that we want to copy from the current position to the end of the LOB */
     826           3 :                 length = -1;
     827             :         }
     828             : 
     829           5 :         if (php_oci_lob_copy(descriptor_dest, descriptor_from, length TSRMLS_CC)) {
     830           3 :                 RETURN_FALSE;
     831             :         }
     832           2 :         RETURN_TRUE;
     833             : }
     834             : /* }}} */
     835             : 
     836             : /* {{{ proto bool oci_lob_is_equal( object lob1, object lob2 )
     837             :    Tests to see if two LOB/FILE locators are equal */
     838           1 : PHP_FUNCTION(oci_lob_is_equal)
     839             : {
     840             :         zval **tmp_first, **tmp_second, *z_descriptor_first, *z_descriptor_second;
     841             :         php_oci_descriptor *descriptor_first, *descriptor_second;
     842             :         boolean is_equal;
     843             :                 
     844           1 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "OO", &z_descriptor_first, oci_lob_class_entry_ptr, &z_descriptor_second, oci_lob_class_entry_ptr) == FAILURE) {
     845           0 :                 return;
     846             :         }
     847             :         
     848           1 :         if (zend_hash_find(Z_OBJPROP_P(z_descriptor_first), "descriptor", sizeof("descriptor"), (void **)&tmp_first) == FAILURE) {
     849           0 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find descriptor property. The first argument should be valid descriptor object");
     850           0 :                 RETURN_FALSE;
     851             :         }
     852             :         
     853           1 :         if (zend_hash_find(Z_OBJPROP_P(z_descriptor_second), "descriptor", sizeof("descriptor"), (void **)&tmp_second) == FAILURE) {
     854           0 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find descriptor property. The second argument should be valid descriptor object");
     855           0 :                 RETURN_FALSE;
     856             :         }
     857             :         
     858           1 :         PHP_OCI_ZVAL_TO_DESCRIPTOR(*tmp_first, descriptor_first);
     859           1 :         PHP_OCI_ZVAL_TO_DESCRIPTOR(*tmp_second, descriptor_second);
     860             : 
     861           1 :         if (php_oci_lob_is_equal(descriptor_first, descriptor_second, &is_equal TSRMLS_CC)) {
     862           0 :                 RETURN_FALSE;
     863             :         }
     864             :         
     865           1 :         if (is_equal == TRUE) {
     866           1 :                 RETURN_TRUE;
     867             :         }
     868           0 :         RETURN_FALSE;
     869             : }
     870             : /* }}} */
     871             : 
     872             : /* {{{ proto bool oci_lob_export([string filename [, int start [, int length]]])
     873             :    Writes a large object into a file */
     874           5 : PHP_FUNCTION(oci_lob_export)
     875             : {       
     876           5 :         zval **tmp, *z_descriptor = getThis();
     877             :         php_oci_descriptor *descriptor;
     878             :         char *filename;
     879             :         char *buffer;
     880             :         int filename_len;
     881           5 :         long start = -1, length = -1, block_length;
     882             :         php_stream *stream;
     883             :         ub4 lob_length;
     884             : 
     885           5 :         if (getThis()) {
     886             : #if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3) || (PHP_MAJOR_VERSION > 5)
     887             :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|ll", &filename, &filename_len, &start, &length) == FAILURE) {
     888             : #else
     889           2 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ll", &filename, &filename_len, &start, &length) == FAILURE) {
     890             : #endif
     891           0 :                         return;
     892             :                 }
     893             :         
     894           2 :                 if (ZEND_NUM_ARGS() > 1 && start < 0) {
     895           0 :                         php_error_docref(NULL TSRMLS_CC, E_WARNING, "Start parameter must be greater than or equal to 0");
     896           0 :                         RETURN_FALSE;
     897             :                 }
     898           2 :                 if (ZEND_NUM_ARGS() > 2 && length < 0) {
     899           0 :                         php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length parameter must be greater than or equal to 0");
     900           0 :                         RETURN_FALSE;
     901             :                 }
     902             :         }
     903             :         else {
     904             : #if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3) || (PHP_MAJOR_VERSION > 5)
     905             :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Op|ll", &z_descriptor, oci_lob_class_entry_ptr, &filename, &filename_len, &start, &length) == FAILURE) {
     906             : #else
     907           3 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Os|ll", &z_descriptor, oci_lob_class_entry_ptr, &filename, &filename_len, &start, &length) == FAILURE) {
     908             : #endif
     909           3 :                         return;
     910             :                 }
     911             :                         
     912           0 :                 if (ZEND_NUM_ARGS() > 2 && start < 0) {
     913           0 :                         php_error_docref(NULL TSRMLS_CC, E_WARNING, "Start parameter must be greater than or equal to 0");
     914           0 :                         RETURN_FALSE;
     915             :                 }
     916           0 :                 if (ZEND_NUM_ARGS() > 3 && length < 0) {
     917           0 :                         php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length parameter must be greater than or equal to 0");
     918           0 :                         RETURN_FALSE;
     919             :                 }
     920             :         }
     921             : 
     922             : #if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 4) || (PHP_MAJOR_VERSION < 5)
     923             :         /* The "p" parsing parameter handles this case in PHP 5.4+ */
     924           2 :         if (strlen(filename) != filename_len) {
     925           1 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Filename cannot contain null bytes");
     926           1 :                 RETURN_FALSE;  
     927             :         }
     928             : #endif
     929             : 
     930           1 :         if (zend_hash_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor"), (void **)&tmp) == FAILURE) {
     931           0 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find descriptor property");
     932           0 :                 RETURN_FALSE;
     933             :         }
     934             :         
     935           1 :         PHP_OCI_ZVAL_TO_DESCRIPTOR(*tmp, descriptor);
     936             :         
     937           1 :         if (php_oci_lob_get_length(descriptor, &lob_length TSRMLS_CC)) {
     938           0 :                 RETURN_FALSE;
     939             :         }               
     940             :         
     941           1 :         if (start == -1) {
     942           0 :                 start = 0;
     943             :         }
     944             : 
     945           1 :         if (length == -1) {
     946           0 :                 length = lob_length - descriptor->lob_current_position;
     947             :         }
     948             :         
     949           1 :         if (length == 0) {
     950             :                 /* nothing to write, fail silently */
     951           0 :                 RETURN_FALSE;
     952             :         }
     953             : 
     954             : #if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 4) || (PHP_MAJOR_VERSION < 5)
     955             :         /* Safe mode has been removed in PHP 5.4 */
     956           1 :         if (PG(safe_mode) && (!php_checkuid(filename, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
     957           0 :                 RETURN_FALSE;
     958             :         }
     959             : #endif
     960             : 
     961           1 :         if (php_check_open_basedir(filename TSRMLS_CC)) {
     962           0 :                 RETURN_FALSE;
     963             :         }
     964             : 
     965             : #if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3) || (PHP_MAJOR_VERSION > 5)
     966             :         stream = php_stream_open_wrapper_ex(filename, "w", REPORT_ERRORS, NULL, NULL);
     967             : #else
     968           1 :         stream = php_stream_open_wrapper_ex(filename, "w", ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL, NULL);
     969             : #endif
     970             : 
     971           1 :         block_length = PHP_OCI_LOB_BUFFER_SIZE;
     972           1 :         if (block_length > length) {
     973           1 :                 block_length = length;
     974             :         }
     975             : 
     976           3 :         while(length > 0) {
     977           1 :                 ub4 tmp_bytes_read = 0;
     978           1 :                 if (php_oci_lob_read(descriptor, block_length, start, &buffer, &tmp_bytes_read TSRMLS_CC)) {
     979           0 :                         php_stream_close(stream);
     980           0 :                         RETURN_FALSE;
     981             :                 }
     982           1 :                 if (tmp_bytes_read && !php_stream_write(stream, buffer, tmp_bytes_read)) {
     983           0 :                         php_stream_close(stream);
     984           0 :                         efree(buffer);
     985           0 :                         RETURN_FALSE;
     986             :                 }
     987           1 :                 if (buffer) {
     988           1 :                         efree(buffer);
     989             :                 }
     990             :                 
     991           1 :                 length -= tmp_bytes_read;
     992           1 :                 descriptor->lob_current_position += tmp_bytes_read;
     993           1 :                 start += tmp_bytes_read;
     994             : 
     995           1 :                 if (block_length > length) {
     996           1 :                         block_length = length;
     997             :                 }
     998             :         }
     999             : 
    1000           1 :         php_stream_close(stream);
    1001           1 :         RETURN_TRUE;
    1002             : }
    1003             : /* }}} */
    1004             : 
    1005             : /* {{{ proto bool oci_lob_write_temporary(string var [, int lob_type])
    1006             :    Writes temporary blob */
    1007         116 : PHP_FUNCTION(oci_lob_write_temporary)
    1008             : {
    1009         116 :         zval **tmp, *z_descriptor = getThis();
    1010             :         php_oci_descriptor *descriptor;
    1011             :         char *data;
    1012             :         int data_len;
    1013         116 :         long type = OCI_TEMP_CLOB;
    1014             : 
    1015         116 :         if (getThis()) {
    1016         116 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &data, &data_len, &type) == FAILURE) {
    1017           0 :                         return;
    1018             :                 }
    1019             :         }
    1020             :         else {
    1021           0 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Os|l", &z_descriptor, oci_lob_class_entry_ptr, &data, &data_len, &type) == FAILURE) {
    1022           0 :                         return;
    1023             :                 }       
    1024             :         }
    1025             :         
    1026         116 :         if (zend_hash_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor"), (void **)&tmp) == FAILURE) {
    1027           0 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find descriptor property");
    1028           0 :                 RETURN_FALSE;
    1029             :         }
    1030             :         
    1031         116 :         PHP_OCI_ZVAL_TO_DESCRIPTOR(*tmp, descriptor);
    1032             : 
    1033         116 :         if (php_oci_lob_write_tmp(descriptor, type, data, data_len TSRMLS_CC)) {
    1034           1 :                 RETURN_FALSE;
    1035             :         }
    1036         115 :         RETURN_TRUE;
    1037             : }
    1038             : /* }}} */
    1039             : 
    1040             : /* {{{ proto bool oci_lob_close()
    1041             :    Closes lob descriptor */
    1042         115 : PHP_FUNCTION(oci_lob_close)
    1043             : {
    1044         115 :         zval **tmp, *z_descriptor = getThis();
    1045             :         php_oci_descriptor *descriptor;
    1046             :         
    1047         115 :         if (!getThis()) {
    1048           0 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &z_descriptor, oci_lob_class_entry_ptr) == FAILURE) {
    1049           0 :                         return;
    1050             :                 }       
    1051             :         }
    1052             :         
    1053         115 :         if (zend_hash_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor"), (void **)&tmp) == FAILURE) {
    1054           0 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find descriptor property");
    1055           0 :                 RETURN_FALSE;
    1056             :         }
    1057             :         
    1058         115 :         PHP_OCI_ZVAL_TO_DESCRIPTOR(*tmp, descriptor);
    1059             : 
    1060         115 :         if (php_oci_lob_close(descriptor TSRMLS_CC)) {
    1061           0 :                 RETURN_FALSE;
    1062             :         }
    1063         115 :         RETURN_TRUE;
    1064             : }
    1065             : /* }}} */
    1066             : 
    1067             : /* {{{ proto object oci_new_descriptor(resource connection [, int type])
    1068             :    Initialize a new empty descriptor LOB/FILE (LOB is default) */
    1069         203 : PHP_FUNCTION(oci_new_descriptor)
    1070             : {
    1071             :         zval *z_connection;
    1072             :         php_oci_connection *connection;
    1073             :         php_oci_descriptor *descriptor;
    1074         203 :         long type = OCI_DTYPE_LOB;
    1075             : 
    1076         203 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|l", &z_connection, &type) == FAILURE) {
    1077           2 :                 return;
    1078             :         }
    1079             : 
    1080         201 :         PHP_OCI_ZVAL_TO_CONNECTION(z_connection, connection);
    1081             : 
    1082             :         /* php_oci_lob_create() checks type */
    1083         201 :         descriptor = php_oci_lob_create(connection, type TSRMLS_CC);    
    1084             :         
    1085         201 :         if (!descriptor) {
    1086           4 :                 RETURN_NULL();
    1087             :         }
    1088             : 
    1089         197 :         object_init_ex(return_value, oci_lob_class_entry_ptr);
    1090         197 :         add_property_resource(return_value, "descriptor", descriptor->id);
    1091             : }
    1092             : /* }}} */
    1093             : 
    1094             : /* {{{ proto bool oci_rollback(resource connection)
    1095             :    Rollback the current context */
    1096           6 : PHP_FUNCTION(oci_rollback)
    1097             : {
    1098             :         zval *z_connection;
    1099             :         php_oci_connection *connection;
    1100             : 
    1101           6 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &z_connection) == FAILURE) {
    1102           1 :                 return;
    1103             :         }
    1104             : 
    1105           5 :         PHP_OCI_ZVAL_TO_CONNECTION(z_connection, connection);
    1106             : 
    1107           5 :         if (connection->descriptors) {
    1108           1 :                 php_oci_connection_descriptors_free(connection TSRMLS_CC);
    1109             :         }
    1110             : 
    1111           5 :         if (php_oci_connection_rollback(connection TSRMLS_CC)) {
    1112           0 :                 RETURN_FALSE;
    1113             :         }
    1114           5 :         RETURN_TRUE;
    1115             : }
    1116             : /* }}} */
    1117             : 
    1118             : /* {{{ proto bool oci_commit(resource connection)
    1119             :    Commit the current context */
    1120          90 : PHP_FUNCTION(oci_commit)
    1121             : {
    1122             :         zval *z_connection;
    1123             :         php_oci_connection *connection;
    1124             : 
    1125          90 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &z_connection) == FAILURE) {
    1126           1 :                 return;
    1127             :         }
    1128             : 
    1129          89 :         PHP_OCI_ZVAL_TO_CONNECTION(z_connection, connection);
    1130             : 
    1131          89 :         if (connection->descriptors) {
    1132          51 :                 php_oci_connection_descriptors_free(connection TSRMLS_CC);
    1133             :         }
    1134             :         
    1135          89 :         if (php_oci_connection_commit(connection TSRMLS_CC)) {
    1136           1 :                 RETURN_FALSE;
    1137             :         }
    1138          88 :         RETURN_TRUE;
    1139             : }
    1140             : /* }}} */
    1141             : 
    1142             : /* {{{ proto string oci_field_name(resource stmt, int col)
    1143             :    Tell the name of a column */
    1144          54 : PHP_FUNCTION(oci_field_name)
    1145             : {
    1146             :         php_oci_out_column *column;
    1147             : 
    1148          54 :         if ( ( column = php_oci_statement_get_column_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0) ) ) {
    1149          49 :                 RETURN_STRINGL(column->name, column->name_len, 1);
    1150             :         }
    1151           5 :         RETURN_FALSE;
    1152             : }
    1153             : /* }}} */
    1154             : 
    1155             : /* {{{ proto int oci_field_size(resource stmt, int col)
    1156             :    Tell the maximum data size of a column */
    1157          34 : PHP_FUNCTION(oci_field_size)
    1158             : {
    1159             :         php_oci_out_column *column;
    1160             : 
    1161          34 :         if ( ( column = php_oci_statement_get_column_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0) ) ) {
    1162             :                 /* Handle data type of LONG */
    1163          28 :                 if (column->data_type == SQLT_LNG){
    1164           0 :                         RETURN_LONG(column->storage_size4);
    1165             :                 }
    1166          28 :                 RETURN_LONG(column->data_size);
    1167             :         }
    1168           6 :         RETURN_FALSE;
    1169             : }
    1170             : /* }}} */
    1171             : 
    1172             : /* {{{ proto int oci_field_scale(resource stmt, int col)
    1173             :    Tell the scale of a column */
    1174          49 : PHP_FUNCTION(oci_field_scale)
    1175             : {
    1176             :         php_oci_out_column *column;
    1177             : 
    1178          49 :         if ( ( column = php_oci_statement_get_column_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0) ) ) {
    1179          44 :                 RETURN_LONG(column->scale);
    1180             :         }
    1181           5 :         RETURN_FALSE;
    1182             : }
    1183             : /* }}} */
    1184             : 
    1185             : /* {{{ proto int oci_field_precision(resource stmt, int col)
    1186             :    Tell the precision of a column */
    1187          49 : PHP_FUNCTION(oci_field_precision)
    1188             : {
    1189             :         php_oci_out_column *column;
    1190             : 
    1191          49 :         if ( ( column = php_oci_statement_get_column_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0) ) ) {
    1192          44 :                 RETURN_LONG(column->precision);
    1193             :         }
    1194           5 :         RETURN_FALSE;
    1195             : }
    1196             : /* }}} */
    1197             : 
    1198             : /* {{{ proto mixed oci_field_type(resource stmt, int col)
    1199             :    Tell the data type of a column */
    1200          34 : PHP_FUNCTION(oci_field_type)
    1201             : {
    1202             :         php_oci_out_column *column;
    1203             : 
    1204          34 :         column = php_oci_statement_get_column_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
    1205             : 
    1206          34 :         if (!column) {
    1207           5 :                 RETURN_FALSE;
    1208             :         }
    1209             :         
    1210          29 :         switch (column->data_type) {
    1211             : #ifdef SQLT_TIMESTAMP
    1212             :                 case SQLT_TIMESTAMP:
    1213           2 :                         RETVAL_STRING("TIMESTAMP",1);
    1214           2 :                         break;
    1215             : #endif
    1216             : #ifdef SQLT_TIMESTAMP_TZ
    1217             :                 case SQLT_TIMESTAMP_TZ:
    1218           2 :                         RETVAL_STRING("TIMESTAMP WITH TIMEZONE",1);
    1219           2 :                         break;
    1220             : #endif
    1221             : #ifdef SQLT_TIMESTAMP_LTZ
    1222             :                 case SQLT_TIMESTAMP_LTZ:
    1223           1 :                         RETVAL_STRING("TIMESTAMP WITH LOCAL TIMEZONE",1);
    1224           1 :                         break;
    1225             : #endif
    1226             : #ifdef SQLT_INTERVAL_YM
    1227             :                 case SQLT_INTERVAL_YM:
    1228           2 :                         RETVAL_STRING("INTERVAL YEAR TO MONTH",1);
    1229           2 :                         break;
    1230             : #endif
    1231             : #ifdef SQLT_INTERVAL_DS
    1232             :                 case SQLT_INTERVAL_DS:
    1233           2 :                         RETVAL_STRING("INTERVAL DAY TO SECOND",1);
    1234           2 :                         break;
    1235             : #endif
    1236             :                 case SQLT_DAT:
    1237           1 :                         RETVAL_STRING("DATE",1);
    1238           1 :                         break;
    1239             :                 case SQLT_NUM:
    1240           7 :                         RETVAL_STRING("NUMBER",1);
    1241           7 :                         break;
    1242             :                 case SQLT_LNG:
    1243           0 :                         RETVAL_STRING("LONG",1);
    1244           0 :                         break;
    1245             :                 case SQLT_BIN:
    1246           0 :                         RETVAL_STRING("RAW",1);
    1247           0 :                         break;
    1248             :                 case SQLT_LBI:
    1249           0 :                         RETVAL_STRING("LONG RAW",1);
    1250           0 :                         break;
    1251             :                 case SQLT_CHR:
    1252           4 :                         RETVAL_STRING("VARCHAR2",1);
    1253           4 :                         break;
    1254             :                 case SQLT_RSET:
    1255           0 :                         RETVAL_STRING("REFCURSOR",1);
    1256           0 :                         break;
    1257             :                 case SQLT_AFC:
    1258           2 :                         RETVAL_STRING("CHAR",1);
    1259           2 :                         break;
    1260             :                 case SQLT_BLOB:
    1261           3 :                         RETVAL_STRING("BLOB",1);
    1262           3 :                         break;
    1263             :                 case SQLT_CLOB:
    1264           3 :                         RETVAL_STRING("CLOB",1);
    1265           3 :                         break;
    1266             :                 case SQLT_BFILE:
    1267           0 :                         RETVAL_STRING("BFILE",1);
    1268           0 :                         break;
    1269             :                 case SQLT_RDD:
    1270           0 :                         RETVAL_STRING("ROWID",1);
    1271           0 :                         break;
    1272             :                 default:
    1273           0 :                         RETVAL_LONG(column->data_type);
    1274             :         }
    1275             : }
    1276             : /* }}} */
    1277             : 
    1278             : /* {{{ proto int oci_field_type_raw(resource stmt, int col)
    1279             :    Tell the raw oracle data type of a column */
    1280          33 : PHP_FUNCTION(oci_field_type_raw)
    1281             : {
    1282             :         php_oci_out_column *column;
    1283             : 
    1284          33 :         column = php_oci_statement_get_column_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
    1285          33 :         if (column) {
    1286          28 :                 RETURN_LONG(column->data_type);
    1287             :         }
    1288           5 :         RETURN_FALSE;
    1289             : }
    1290             : /* }}} */
    1291             : 
    1292             : /* {{{ proto bool oci_field_is_null(resource stmt, int col)
    1293             :    Tell whether a column is NULL */
    1294          33 : PHP_FUNCTION(oci_field_is_null)
    1295             : {
    1296             :         php_oci_out_column *column;
    1297             : 
    1298          33 :         if ( ( column = php_oci_statement_get_column_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0) ) ) {
    1299          28 :                 if (column->indicator == -1) {
    1300           9 :                         RETURN_TRUE;
    1301             :                 }
    1302             :         }
    1303          24 :         RETURN_FALSE;
    1304             : }
    1305             : /* }}} */
    1306             : 
    1307             : /* {{{ proto void oci_internal_debug(int onoff)
    1308             :    Toggle internal debugging output for the OCI extension */
    1309           3 : PHP_FUNCTION(oci_internal_debug)
    1310             : {
    1311             :         zend_bool on_off;
    1312             : 
    1313           3 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &on_off) == FAILURE) {
    1314           1 :                 return;
    1315             :         }
    1316           2 :         OCI_G(debug_mode) = on_off;
    1317             : }
    1318             : /* }}} */
    1319             : 
    1320             : /* {{{ proto bool oci_execute(resource stmt [, int mode])
    1321             :    Execute a parsed statement */
    1322       37747 : PHP_FUNCTION(oci_execute)
    1323             : {
    1324             :         zval *z_statement;
    1325             :         php_oci_statement *statement;
    1326       37747 :         long mode = OCI_COMMIT_ON_SUCCESS;
    1327             : 
    1328       37747 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|l", &z_statement, &mode) == FAILURE) {
    1329           1 :                 return;
    1330             :         }
    1331             : 
    1332       37746 :         PHP_OCI_ZVAL_TO_STATEMENT(z_statement, statement);
    1333             : 
    1334       37746 :         if (php_oci_statement_execute(statement, mode TSRMLS_CC)) {
    1335         257 :                 RETURN_FALSE;
    1336             :         }
    1337       37489 :         RETURN_TRUE;
    1338             : }
    1339             : /* }}} */
    1340             : 
    1341             : /* {{{ proto bool oci_cancel(resource stmt)
    1342             :    Cancel reading from a cursor */
    1343           5 : PHP_FUNCTION(oci_cancel)
    1344             : {
    1345             :         zval *z_statement;
    1346             :         php_oci_statement *statement;
    1347             : 
    1348           5 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &z_statement) == FAILURE) {
    1349           1 :                 return;
    1350             :         }
    1351             : 
    1352           4 :         PHP_OCI_ZVAL_TO_STATEMENT(z_statement, statement);
    1353             : 
    1354           4 :         if (php_oci_statement_cancel(statement TSRMLS_CC)) {
    1355           0 :                 RETURN_FALSE;
    1356             :         }
    1357           4 :         RETURN_TRUE;
    1358             : }
    1359             : /* }}} */
    1360             : 
    1361             : /* {{{ proto bool oci_fetch(resource stmt)
    1362             :    Prepare a new row of data for reading */
    1363         256 : PHP_FUNCTION(oci_fetch)
    1364             : {
    1365             :         zval *z_statement;
    1366             :         php_oci_statement *statement;
    1367         256 :         ub4 nrows = 1; /* only one row at a time is supported for now */
    1368             : 
    1369         256 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &z_statement) == FAILURE) {
    1370           1 :                 return;
    1371             :         }
    1372             : 
    1373         255 :         PHP_OCI_ZVAL_TO_STATEMENT(z_statement, statement);
    1374             : 
    1375         255 :         if (php_oci_statement_fetch(statement, nrows TSRMLS_CC)) {
    1376         103 :                 RETURN_FALSE;
    1377             :         }
    1378         152 :         RETURN_TRUE;
    1379             : }
    1380             : /* }}} */
    1381             : 
    1382             : /* {{{ proto int ocifetchinto(resource stmt, array &output [, int mode])
    1383             :    Fetch a row of result data into an array */
    1384        6625 : PHP_FUNCTION(ocifetchinto)
    1385             : {
    1386        6625 :         php_oci_fetch_row(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_OCI_NUM, 3);
    1387        6625 : }
    1388             : /* }}} */
    1389             : 
    1390             : /* {{{ proto int oci_fetch_all(resource stmt, array &output[, int skip[, int maxrows[, int flags]]])
    1391             :    Fetch all rows of result data into an array */
    1392         134 : PHP_FUNCTION(oci_fetch_all)
    1393             : {
    1394             :         zval *z_statement, *array, *element, *tmp;
    1395             :         php_oci_statement *statement;
    1396             :         php_oci_out_column **columns;
    1397             :         zval ***outarrs;
    1398         134 :         ub4 nrows = 1;
    1399             :         int i;
    1400         134 :         long rows = 0, flags = 0, skip = 0, maxrows = -1;
    1401             : 
    1402         134 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz/|lll", &z_statement, &array, &skip, &maxrows, &flags) == FAILURE) {
    1403           1 :                 return;
    1404             :         }
    1405             : 
    1406         133 :         PHP_OCI_ZVAL_TO_STATEMENT(z_statement, statement);
    1407             : 
    1408         133 :         zval_dtor(array);
    1409         133 :         array_init(array);
    1410             : 
    1411         133 :         while (skip--) {
    1412           8 :                 if (php_oci_statement_fetch(statement, nrows TSRMLS_CC)) {
    1413           2 :                         RETURN_LONG(0);
    1414             :                 }
    1415             :         }
    1416             : 
    1417         131 :         if (flags & PHP_OCI_FETCHSTATEMENT_BY_ROW) {
    1418          17 :                 columns = safe_emalloc(statement->ncolumns, sizeof(php_oci_out_column *), 0);
    1419             : 
    1420          75 :                 for (i = 0; i < statement->ncolumns; i++) {
    1421          58 :                         columns[ i ] = php_oci_statement_get_column(statement, i + 1, NULL, 0 TSRMLS_CC);
    1422             :                 }
    1423             : 
    1424          78 :                 while (!php_oci_statement_fetch(statement, nrows TSRMLS_CC)) {
    1425             :                         zval *row;
    1426             :                         
    1427          46 :                         MAKE_STD_ZVAL(row);
    1428          46 :                         array_init(row);
    1429             : 
    1430         217 :                         for (i = 0; i < statement->ncolumns; i++) {
    1431         171 :                                 MAKE_STD_ZVAL(element);
    1432         171 :                                 php_oci_column_to_zval(columns[ i ], element, PHP_OCI_RETURN_LOBS TSRMLS_CC);
    1433             : 
    1434         171 :                                 if (flags & PHP_OCI_NUM) {
    1435          42 :                                         zend_hash_next_index_insert(Z_ARRVAL_P(row), &element, sizeof(zval*), NULL);
    1436             :                                 } else { /* default to ASSOC */
    1437             : #if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 1) || (PHP_MAJOR_VERSION > 5)
    1438             :                                         /* zend_symtable_update is only available in 5.2+ */
    1439         129 :                                         zend_symtable_update(Z_ARRVAL_P(row), columns[ i ]->name, columns[ i ]->name_len+1, &element, sizeof(zval*), NULL);
    1440             : #else
    1441             :                                         /* This code path means Bug #45458 will remain broken when OCI8 is built with PHP 4 */
    1442             :                                         zend_hash_update(Z_ARRVAL_P(row), columns[ i ]->name, columns[ i ]->name_len+1, &element, sizeof(zval*), NULL);
    1443             : #endif
    1444             :                                 }
    1445             :                         }
    1446             : 
    1447          46 :                         zend_hash_next_index_insert(Z_ARRVAL_P(array), &row, sizeof(zval*), NULL);
    1448          46 :                         rows++;
    1449             : 
    1450          46 :                         if (maxrows != -1 && rows == maxrows) {
    1451           2 :                                 php_oci_statement_cancel(statement TSRMLS_CC);
    1452           2 :                                 break;
    1453             :                         }
    1454             :                 }
    1455          17 :                 efree(columns);
    1456             : 
    1457             :         } else { /* default to BY_COLUMN */
    1458         114 :                 columns = safe_emalloc(statement->ncolumns, sizeof(php_oci_out_column *), 0);
    1459         114 :                 outarrs = safe_emalloc(statement->ncolumns, sizeof(zval*), 0);
    1460             :                 
    1461         114 :                 if (flags & PHP_OCI_NUM) {
    1462          24 :                         for (i = 0; i < statement->ncolumns; i++) {
    1463          18 :                                 columns[ i ] = php_oci_statement_get_column(statement, i + 1, NULL, 0 TSRMLS_CC);
    1464             :                                 
    1465          18 :                                 MAKE_STD_ZVAL(tmp);
    1466          18 :                                 array_init(tmp);
    1467          18 :                                 zend_hash_next_index_insert(Z_ARRVAL_P(array), &tmp, sizeof(zval*), (void **) &(outarrs[ i ]));
    1468             :                         }
    1469             :                 } else { /* default to ASSOC */
    1470         271 :                         for (i = 0; i < statement->ncolumns; i++) {
    1471         163 :                                 columns[ i ] = php_oci_statement_get_column(statement, i + 1, NULL, 0 TSRMLS_CC);
    1472             :                                 
    1473         163 :                                 MAKE_STD_ZVAL(tmp);
    1474         163 :                                 array_init(tmp);
    1475             : #if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 1) || (PHP_MAJOR_VERSION > 5)
    1476             :                                 /* zend_symtable_update is only available in 5.2+ */
    1477         163 :                                 zend_symtable_update(Z_ARRVAL_P(array), columns[ i ]->name, columns[ i ]->name_len+1, (void *) &tmp, sizeof(zval*), (void **) &(outarrs[ i ]));
    1478             : #else
    1479             :                                 /* This code path means Bug #45458 will remain broken when OCI8 is built with PHP 4 */
    1480             :                                 zend_hash_update(Z_ARRVAL_P(array), columns[ i ]->name, columns[ i ]->name_len+1, (void *) &tmp, sizeof(zval*), (void **) &(outarrs[ i ]));
    1481             : #endif
    1482             :                         }
    1483             :                 }
    1484             : 
    1485         396 :                 while (!php_oci_statement_fetch(statement, nrows TSRMLS_CC)) {
    1486         486 :                         for (i = 0; i < statement->ncolumns; i++) {
    1487         316 :                                 MAKE_STD_ZVAL(element);
    1488         316 :                                 php_oci_column_to_zval(columns[ i ], element, PHP_OCI_RETURN_LOBS TSRMLS_CC);
    1489         316 :                                 zend_hash_index_update((*(outarrs[ i ]))->value.ht, rows, (void *)&element, sizeof(zval*), NULL);
    1490             :                         }
    1491             : 
    1492         170 :                         rows++;
    1493             : 
    1494         170 :                         if (maxrows != -1 && rows == maxrows) {
    1495           2 :                                 php_oci_statement_cancel(statement TSRMLS_CC);
    1496           2 :                                 break;
    1497             :                         }
    1498             :                 }
    1499             :                 
    1500         114 :                 efree(columns);
    1501         114 :                 efree(outarrs);
    1502             :         }
    1503             : 
    1504         131 :         RETURN_LONG(rows);
    1505             : }
    1506             : /* }}} */
    1507             : 
    1508             : /* {{{ proto object oci_fetch_object( resource stmt )
    1509             :    Fetch a result row as an object */
    1510          26 : PHP_FUNCTION(oci_fetch_object)
    1511             : {
    1512          26 :         php_oci_fetch_row(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_OCI_ASSOC | PHP_OCI_RETURN_NULLS, 2);
    1513             : 
    1514          26 :         if (Z_TYPE_P(return_value) == IS_ARRAY) {
    1515          20 :                 object_and_properties_init(return_value, ZEND_STANDARD_CLASS_DEF_PTR, Z_ARRVAL_P(return_value));
    1516             :         }
    1517          26 : }
    1518             : /* }}} */
    1519             : 
    1520             : /* {{{ proto array oci_fetch_row( resource stmt )
    1521             :    Fetch a result row as an enumerated array */
    1522          67 : PHP_FUNCTION(oci_fetch_row)
    1523             : {
    1524          67 :         php_oci_fetch_row(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_OCI_NUM | PHP_OCI_RETURN_NULLS, 1);
    1525          67 : }
    1526             : /* }}} */
    1527             : 
    1528             : /* {{{ proto array oci_fetch_assoc( resource stmt )
    1529             :    Fetch a result row as an associative array */
    1530      120061 : PHP_FUNCTION(oci_fetch_assoc)
    1531             : {
    1532      120061 :         php_oci_fetch_row(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_OCI_ASSOC | PHP_OCI_RETURN_NULLS, 1);
    1533      120061 : }
    1534             : /* }}} */
    1535             : 
    1536             : /* {{{ proto array oci_fetch_array( resource stmt [, int mode ])
    1537             :    Fetch a result row as an array */
    1538      104665 : PHP_FUNCTION(oci_fetch_array)
    1539             : {
    1540      104665 :         php_oci_fetch_row(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_OCI_BOTH | PHP_OCI_RETURN_NULLS, 2);
    1541      104665 : }
    1542             : /* }}} */
    1543             : 
    1544             : /* {{{ proto bool oci_free_statement(resource stmt)
    1545             :    Free all resources associated with a statement */
    1546       32154 : PHP_FUNCTION(oci_free_statement)
    1547             : {
    1548             :         zval *z_statement;
    1549             :         php_oci_statement *statement;
    1550             : 
    1551       32154 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &z_statement) == FAILURE) {
    1552           3 :                 return;
    1553             :         }
    1554             : 
    1555       32151 :         PHP_OCI_ZVAL_TO_STATEMENT(z_statement, statement);
    1556             : 
    1557       32151 :         zend_list_delete(statement->id);
    1558       32151 :         RETURN_TRUE;
    1559             : }
    1560             : /* }}} */
    1561             : 
    1562             : /* {{{ proto bool oci_close(resource connection)
    1563             :    Disconnect from database */
    1564          75 : PHP_FUNCTION(oci_close)
    1565             : {
    1566             :         /* oci_close for pconnect (if old_oci_close_semantics not set) would
    1567             :          * release the connection back to the client-side session pool (and to the
    1568             :          * server-side pool if Database Resident Connection Pool is being used).
    1569             :          * Subsequent pconnects in the same script are not guaranteed to get the
    1570             :          * same database session.
    1571             :          */
    1572             : 
    1573             :         zval *z_connection;
    1574             :         php_oci_connection *connection;
    1575             : 
    1576          75 :         if (OCI_G(old_oci_close_semantics)) {
    1577             :                 /* do nothing to keep BC */
    1578           8 :                 return;
    1579             :         }
    1580             :         
    1581          67 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &z_connection) == FAILURE) {
    1582           1 :                 return;
    1583             :         }
    1584             : 
    1585          66 :         PHP_OCI_ZVAL_TO_CONNECTION(z_connection, connection);
    1586          66 :         zend_list_delete(connection->rsrc_id);
    1587             : 
    1588          66 :         ZVAL_NULL(z_connection);
    1589             :         
    1590          66 :         RETURN_TRUE;
    1591             : }
    1592             : /* }}} */
    1593             : 
    1594             : /* {{{ proto resource oci_new_connect(string user, string pass [, string db])
    1595             :    Connect to an Oracle database and log on. Returns a new session. */
    1596          51 : PHP_FUNCTION(oci_new_connect)
    1597             : {
    1598          51 :         php_oci_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0, 1);
    1599          51 : }
    1600             : /* }}} */
    1601             : 
    1602             : /* {{{ proto resource oci_connect(string user, string pass [, string db [, string charset [, int session_mode ]])
    1603             :    Connect to an Oracle database and log on. Returns a new session. */
    1604         538 : PHP_FUNCTION(oci_connect)
    1605             : {
    1606         538 :         php_oci_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0, 0);
    1607         538 : }
    1608             : /* }}} */
    1609             : 
    1610             : /* {{{ proto resource oci_pconnect(string user, string pass [, string db [, string charset ]])
    1611             :    Connect to an Oracle database using a persistent connection and log on. Returns a new session. */
    1612          62 : PHP_FUNCTION(oci_pconnect)
    1613             : {
    1614          62 :         php_oci_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1, 0);
    1615          62 : }
    1616             : /* }}} */
    1617             : 
    1618             : /* {{{ proto array oci_error([resource stmt|connection|global])
    1619             :    Return the last error of stmt|connection|global. If no error happened returns false. */
    1620         248 : PHP_FUNCTION(oci_error)
    1621             : {
    1622         248 :         zval *arg = NULL;
    1623             :         php_oci_statement *statement;
    1624             :         php_oci_connection *connection;
    1625             :         text *errbuf;
    1626         248 :         sb4 errcode = 0;
    1627         248 :         sword error = OCI_SUCCESS;
    1628         248 :         dvoid *errh = NULL;
    1629         248 :         ub2 error_offset = 0;
    1630         248 :         text *sqltext = NULL;
    1631             : 
    1632         248 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|r", &arg) == FAILURE) {
    1633           2 :                 return;
    1634             :         }
    1635             : 
    1636         246 :         if (ZEND_NUM_ARGS() > 0) {
    1637         197 :                 statement = (php_oci_statement *) zend_fetch_resource(&arg TSRMLS_CC, -1, NULL, NULL, 1, le_statement);
    1638             :         
    1639         197 :                 if (statement) {
    1640         166 :                         errh = statement->err;
    1641         166 :                         error = statement->errcode;
    1642             : 
    1643         166 :                         if (php_oci_fetch_sqltext_offset(statement, &sqltext, &error_offset TSRMLS_CC)) {
    1644           0 :                                 RETURN_FALSE;
    1645             :                         }
    1646         166 :                         goto go_out;
    1647             :                 }
    1648             : 
    1649          31 :                 connection = (php_oci_connection *) zend_fetch_resource(&arg TSRMLS_CC, -1, NULL, NULL, 1, le_connection);
    1650          31 :                 if (connection) {
    1651          27 :                         errh = connection->err;
    1652          27 :                         error = connection->errcode;
    1653          27 :                         goto go_out;
    1654             :                 }
    1655             : 
    1656           4 :                 connection = (php_oci_connection *) zend_fetch_resource(&arg TSRMLS_CC, -1, NULL, NULL, 1, le_pconnection);
    1657           4 :                 if (connection) {
    1658           4 :                         errh = connection->err;
    1659           4 :                         error = connection->errcode;
    1660           4 :                         goto go_out;
    1661             :                 }
    1662             :         } else {
    1663          49 :                 errh = OCI_G(err);
    1664          49 :                 error = OCI_G(errcode);
    1665             :         }
    1666             : 
    1667             : go_out:
    1668         246 :         if (error == OCI_SUCCESS) { /* no error set in the handle */
    1669          53 :                 RETURN_FALSE;
    1670             :         }
    1671             : 
    1672         193 :         if (!errh) {
    1673           0 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Oci_error: unable to find error handle");
    1674           0 :                 RETURN_FALSE;
    1675             :         }
    1676             : 
    1677         193 :         errcode = php_oci_fetch_errmsg(errh, &errbuf TSRMLS_CC);
    1678             : 
    1679         193 :         if (errcode) {
    1680         193 :                 array_init(return_value);
    1681         193 :                 add_assoc_long(return_value, "code", errcode);
    1682         193 :                 add_assoc_string(return_value, "message", (char*) errbuf, 0);
    1683         193 :                 add_assoc_long(return_value, "offset", error_offset);
    1684         193 :                 add_assoc_string(return_value, "sqltext", sqltext ? (char *) sqltext : "", 1);
    1685             :         } else {
    1686           0 :                 RETURN_FALSE;
    1687             :         }
    1688             : }
    1689             : /* }}} */
    1690             : 
    1691             : /* {{{ proto int oci_num_fields(resource stmt)
    1692             :    Return the number of result columns in a statement */
    1693          41 : PHP_FUNCTION(oci_num_fields)
    1694             : {
    1695             :         zval *z_statement;
    1696             :         php_oci_statement *statement;
    1697             : 
    1698          41 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &z_statement) == FAILURE) {
    1699           3 :                 return;
    1700             :         }
    1701             : 
    1702          38 :         PHP_OCI_ZVAL_TO_STATEMENT(z_statement, statement);
    1703             : 
    1704          38 :         RETURN_LONG(statement->ncolumns);
    1705             : }
    1706             : /* }}} */
    1707             : 
    1708             : /* {{{ proto resource oci_parse(resource connection, string statement)
    1709             :    Parse a SQL or PL/SQL statement and return a statement resource */
    1710       33039 : PHP_FUNCTION(oci_parse)
    1711             : {
    1712             :         zval *z_connection;
    1713             :         php_oci_connection *connection;
    1714             :         php_oci_statement *statement;
    1715             :         char *query;
    1716             :         int query_len;
    1717             : 
    1718       33039 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &z_connection, &query, &query_len) == FAILURE) {
    1719           2 :                 return;
    1720             :         }
    1721             : 
    1722       33037 :         PHP_OCI_ZVAL_TO_CONNECTION(z_connection, connection);
    1723             : 
    1724       33037 :         statement = php_oci_statement_create(connection, query, query_len TSRMLS_CC);
    1725             : 
    1726       33037 :         if (statement) {
    1727       33032 :                 RETURN_RESOURCE(statement->id);
    1728             :         }
    1729           5 :         RETURN_FALSE;
    1730             : }
    1731             : /* }}} */
    1732             : 
    1733             : /* {{{ proto bool oci_set_prefetch(resource stmt, int prefetch_rows)
    1734             :   Sets the number of rows to be prefetched on execute to prefetch_rows for stmt */
    1735          19 : PHP_FUNCTION(oci_set_prefetch)
    1736             : {
    1737             :         zval *z_statement;
    1738             :         php_oci_statement *statement;
    1739             :         long size;
    1740             : 
    1741          19 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &z_statement, &size) == FAILURE) {
    1742           1 :                 return;
    1743             :         }
    1744             : 
    1745          18 :         PHP_OCI_ZVAL_TO_STATEMENT(z_statement, statement);
    1746             : 
    1747          18 :         if (php_oci_statement_set_prefetch(statement, size TSRMLS_CC)) {
    1748           2 :                 RETURN_FALSE;
    1749             :         }
    1750          16 :         RETURN_TRUE;
    1751             : }
    1752             : /* }}} */
    1753             : 
    1754             : /* {{{ proto bool oci_set_client_identifier(resource connection, string value)
    1755             :   Sets the client identifier attribute on the connection */
    1756           9 : PHP_FUNCTION(oci_set_client_identifier)
    1757             : {
    1758             :         zval *z_connection;
    1759             :         php_oci_connection *connection;
    1760             :         char *client_id;
    1761             :         int client_id_len;
    1762             : 
    1763           9 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &z_connection, &client_id, &client_id_len) == FAILURE) {
    1764           0 :                 return;
    1765             :         }
    1766             : 
    1767           9 :         PHP_OCI_ZVAL_TO_CONNECTION(z_connection, connection);
    1768             : 
    1769           9 :         PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrSet, ((dvoid *) connection->session, (ub4) OCI_HTYPE_SESSION, (dvoid *) client_id, (ub4) client_id_len, (ub4) OCI_ATTR_CLIENT_IDENTIFIER, OCI_G(err)));
    1770             : 
    1771           9 :         if (OCI_G(errcode) != OCI_SUCCESS) {
    1772           1 :                 php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC);
    1773           1 :                 RETURN_FALSE;
    1774             :         }
    1775             : 
    1776           8 :         RETURN_TRUE;
    1777             : }
    1778             : /* }}} */
    1779             : 
    1780             : /* {{{ proto bool oci_set_edition(string value)
    1781             :   Sets the edition attribute for all subsequent connections created */
    1782          14 : PHP_FUNCTION(oci_set_edition)
    1783             : {
    1784             : #if ((OCI_MAJOR_VERSION > 11) || ((OCI_MAJOR_VERSION == 11) && (OCI_MINOR_VERSION >= 2)))
    1785             :         char *edition;
    1786             :         int edition_len;
    1787             : 
    1788          14 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &edition, &edition_len) == FAILURE) {
    1789           0 :                 return;
    1790             :         }
    1791             : 
    1792          14 :         if (OCI_G(edition)) {
    1793          12 :                 efree(OCI_G(edition));
    1794          12 :                 OCI_G(edition) = NULL;
    1795             :         }
    1796             : 
    1797          14 :         if (edition) {
    1798          14 :                 OCI_G(edition) = (char *)safe_emalloc(edition_len+1, sizeof(text), 0);
    1799          14 :                 memcpy(OCI_G(edition), edition, edition_len);
    1800          14 :                 OCI_G(edition)[edition_len] = '\0';
    1801             :         }
    1802             : 
    1803          14 :         RETURN_TRUE;
    1804             : #else
    1805             :         php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unsupported attribute type");
    1806             :         RETURN_FALSE;
    1807             : #endif
    1808             : }
    1809             : /* }}} */
    1810             : 
    1811             : /* {{{ proto bool oci_set_module_name(resource connection, string value)
    1812             :   Sets the module attribute on the connection */
    1813           9 : PHP_FUNCTION(oci_set_module_name)
    1814             : {
    1815             : #if (OCI_MAJOR_VERSION >= 10)
    1816             :         zval *z_connection;
    1817             :         php_oci_connection *connection;
    1818             :         char *module;
    1819             :         int module_len;
    1820             : 
    1821           9 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &z_connection, &module, &module_len) == FAILURE) {
    1822           0 :                 return;
    1823             :         }
    1824             : 
    1825           9 :         PHP_OCI_ZVAL_TO_CONNECTION(z_connection, connection);
    1826             : 
    1827           9 :         PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrSet, ((dvoid *) connection->session, (ub4) OCI_HTYPE_SESSION, (dvoid *) module, (ub4) module_len, (ub4) OCI_ATTR_MODULE, OCI_G(err)));
    1828             : 
    1829           9 :         if (OCI_G(errcode) != OCI_SUCCESS) {
    1830           1 :                 php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC);
    1831           1 :                 RETURN_FALSE;
    1832             :         }
    1833             : 
    1834           8 :         RETURN_TRUE;
    1835             : #else
    1836             :         php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unsupported attribute type");
    1837             :         RETURN_FALSE;
    1838             : #endif
    1839             : }
    1840             : /* }}} */
    1841             : 
    1842             : /* {{{ proto bool oci_set_action(resource connection, string value)
    1843             :   Sets the action attribute on the connection */
    1844          15 : PHP_FUNCTION(oci_set_action)
    1845             : {
    1846             : #if (OCI_MAJOR_VERSION >= 10)
    1847             :         zval *z_connection;
    1848             :         php_oci_connection *connection;
    1849             :         char *action;
    1850             :         int action_len;
    1851             : 
    1852          15 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &z_connection, &action, &action_len) == FAILURE) {
    1853           2 :                 return;
    1854             :         }
    1855             : 
    1856          13 :         PHP_OCI_ZVAL_TO_CONNECTION(z_connection, connection);
    1857             : 
    1858          13 :         PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrSet, ((dvoid *) connection->session, (ub4) OCI_HTYPE_SESSION, (dvoid *) action, (ub4) action_len, (ub4) OCI_ATTR_ACTION, OCI_G(err)));
    1859             : 
    1860          13 :         if (OCI_G(errcode) != OCI_SUCCESS) {
    1861           1 :                 php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC);
    1862           1 :                 RETURN_FALSE;
    1863             :         }
    1864             : 
    1865          12 :         RETURN_TRUE;
    1866             : #else
    1867             :         php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unsupported attribute type");
    1868             :         RETURN_FALSE;
    1869             : #endif
    1870             : }
    1871             : /* }}} */
    1872             : 
    1873             : /* {{{ proto bool oci_set_client_info(resource connection, string value)
    1874             :   Sets the client info attribute on the connection */
    1875          10 : PHP_FUNCTION(oci_set_client_info)
    1876             : {
    1877             : #if (OCI_MAJOR_VERSION >= 10)
    1878             :         zval *z_connection;
    1879             :         php_oci_connection *connection;
    1880             :         char *client_info;
    1881             :         int client_info_len;
    1882             : 
    1883          10 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &z_connection, &client_info, &client_info_len) == FAILURE) {
    1884           1 :                 return;
    1885             :         }
    1886             : 
    1887           9 :         PHP_OCI_ZVAL_TO_CONNECTION(z_connection, connection);
    1888             : 
    1889           9 :         PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIAttrSet, ((dvoid *) connection->session, (ub4) OCI_HTYPE_SESSION, (dvoid *) client_info, (ub4) client_info_len, (ub4) OCI_ATTR_CLIENT_INFO, OCI_G(err)));
    1890             : 
    1891           9 :         if (OCI_G(errcode) != OCI_SUCCESS) {
    1892           1 :                 php_oci_error(OCI_G(err), OCI_G(errcode) TSRMLS_CC);
    1893           1 :                 RETURN_FALSE;
    1894             :         }
    1895             : 
    1896           8 :         RETURN_TRUE;
    1897             : #else
    1898             :         php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unsupported attribute type");
    1899             :         RETURN_FALSE;
    1900             : #endif
    1901             : }
    1902             : /* }}} */
    1903             : 
    1904             : /* {{{ proto bool oci_password_change(resource connection, string username, string old_password, string new_password)
    1905             :   Changes the password of an account */
    1906           8 : PHP_FUNCTION(oci_password_change)
    1907             : {
    1908             :         zval *z_connection;
    1909             :         char *user, *pass_old, *pass_new, *dbname;
    1910             :         int user_len, pass_old_len, pass_new_len, dbname_len;
    1911             :         php_oci_connection *connection;
    1912             : 
    1913             : #if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 4) || (PHP_MAJOR_VERSION < 5)
    1914             :         /* Safe mode has been removed in PHP 5.4 */
    1915           8 :         if (PG(safe_mode)) {
    1916           1 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "is disabled in Safe Mode");
    1917           1 :                 RETURN_FALSE;
    1918             :         }
    1919             : #endif
    1920             : 
    1921           7 :         if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "rsss", &z_connection, &user, &user_len, &pass_old, &pass_old_len, &pass_new, &pass_new_len) == SUCCESS) {
    1922           2 :                 PHP_OCI_ZVAL_TO_CONNECTION(z_connection, connection);
    1923             : 
    1924           2 :                 if (!user_len) {
    1925           0 :                         php_error_docref(NULL TSRMLS_CC, E_WARNING, "username cannot be empty");
    1926           0 :                         RETURN_FALSE;
    1927             :                 }
    1928           2 :                 if (!pass_old_len) {
    1929           0 :                         php_error_docref(NULL TSRMLS_CC, E_WARNING, "old password cannot be empty");
    1930           0 :                         RETURN_FALSE;
    1931             :                 }
    1932           2 :                 if (!pass_new_len) {
    1933           0 :                         php_error_docref(NULL TSRMLS_CC, E_WARNING, "new password cannot be empty");
    1934           0 :                         RETURN_FALSE;
    1935             :                 }
    1936             : 
    1937           2 :                 if (php_oci_password_change(connection, user, user_len, pass_old, pass_old_len, pass_new, pass_new_len TSRMLS_CC)) {
    1938           0 :                         RETURN_FALSE;
    1939             :                 }
    1940           2 :                 RETURN_TRUE;
    1941           5 :         } else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "ssss", &dbname, &dbname_len, &user, &user_len, &pass_old, &pass_old_len, &pass_new, &pass_new_len) == SUCCESS) {
    1942             : 
    1943           4 :                 if (!user_len) {
    1944           0 :                         php_error_docref(NULL TSRMLS_CC, E_WARNING, "username cannot be empty");
    1945           0 :                         RETURN_FALSE;
    1946             :                 }
    1947           4 :                 if (!pass_old_len) {
    1948           0 :                         php_error_docref(NULL TSRMLS_CC, E_WARNING, "old password cannot be empty");
    1949           0 :                         RETURN_FALSE;
    1950             :                 }
    1951           4 :                 if (!pass_new_len) {
    1952           0 :                         php_error_docref(NULL TSRMLS_CC, E_WARNING, "new password cannot be empty");
    1953           0 :                         RETURN_FALSE;
    1954             :                 }
    1955             : 
    1956           4 :                 connection = php_oci_do_connect_ex(user, user_len, pass_old, pass_old_len, pass_new, pass_new_len, dbname, dbname_len, NULL, OCI_DEFAULT, 0, 0 TSRMLS_CC);
    1957           4 :                 if (!connection) {
    1958           0 :                         RETURN_FALSE;
    1959             :                 }
    1960           4 :                 RETURN_RESOURCE(connection->rsrc_id);
    1961             :         }
    1962           1 :         WRONG_PARAM_COUNT;
    1963             : }
    1964             : /* }}} */
    1965             : 
    1966             : /* {{{ proto resource oci_new_cursor(resource connection)
    1967             :    Return a new cursor (Statement-Handle) - use this to bind ref-cursors! */
    1968          27 : PHP_FUNCTION(oci_new_cursor)
    1969             : {
    1970             :         zval *z_connection;
    1971             :         php_oci_connection *connection;
    1972             :         php_oci_statement *statement;
    1973             : 
    1974          27 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &z_connection) == FAILURE) {
    1975           1 :                 return;
    1976             :         }
    1977             : 
    1978          26 :         PHP_OCI_ZVAL_TO_CONNECTION(z_connection, connection);
    1979             : 
    1980          26 :         statement = php_oci_statement_create(connection, NULL, 0 TSRMLS_CC);
    1981             :         
    1982          26 :         if (statement) {
    1983          26 :                 RETURN_RESOURCE(statement->id);
    1984             :         }
    1985           0 :         RETURN_FALSE;
    1986             : }
    1987             : /* }}} */
    1988             : 
    1989             : /* {{{ proto string oci_result(resource stmt, mixed column)
    1990             :    Return a single column of result data */
    1991         130 : PHP_FUNCTION(oci_result)
    1992             : {
    1993             :         php_oci_out_column *column;
    1994             :         
    1995         130 :         column = php_oci_statement_get_column_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
    1996         130 :         if(column) {
    1997         127 :                 php_oci_column_to_zval(column, return_value, 0 TSRMLS_CC);
    1998             :         }
    1999             :         else {
    2000           3 :                 RETURN_FALSE;
    2001             :         }
    2002             : }
    2003             : /* }}} */
    2004             : 
    2005             : /* {{{ proto string oci_client_version()
    2006             :    Return a string containing runtime client library version information */
    2007          32 : PHP_FUNCTION(oci_client_version)
    2008             : {
    2009          32 :         char *version = NULL;
    2010             : 
    2011          32 :         php_oci_client_get_version(&version TSRMLS_CC);
    2012          32 :         RETURN_STRING(version, 0);
    2013             : }
    2014             : /* }}} */
    2015             : 
    2016             : /* {{{ proto string oci_server_version(resource connection)
    2017             :    Return a string containing server version information */
    2018         257 : PHP_FUNCTION(oci_server_version)
    2019             : {
    2020             :         zval *z_connection;
    2021             :         php_oci_connection *connection;
    2022         257 :         char *version = NULL;
    2023             : 
    2024         257 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &z_connection) == FAILURE) {
    2025           1 :                 return;
    2026             :         }
    2027             : 
    2028         256 :         PHP_OCI_ZVAL_TO_CONNECTION(z_connection, connection);
    2029             : 
    2030         256 :         if (php_oci_server_get_version(connection, &version TSRMLS_CC)) {
    2031           0 :                 RETURN_FALSE;
    2032             :         }
    2033             :         
    2034         256 :         RETURN_STRING(version, 0);
    2035             : }
    2036             : /* }}} */
    2037             : 
    2038             : /* {{{ proto string oci_statement_type(resource stmt)
    2039             :    Return the query type of an OCI statement */
    2040          27 : PHP_FUNCTION(oci_statement_type)
    2041             : {
    2042             :         zval *z_statement;
    2043             :         php_oci_statement *statement;
    2044             :         ub2 type;
    2045             : 
    2046          27 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &z_statement) == FAILURE) {
    2047           1 :                 return;
    2048             :         }
    2049             : 
    2050          26 :         PHP_OCI_ZVAL_TO_STATEMENT(z_statement, statement);
    2051             : 
    2052          26 :         if (php_oci_statement_get_type(statement, &type TSRMLS_CC)) {
    2053           0 :                 RETURN_FALSE;
    2054             :         }
    2055             : 
    2056          26 :         switch (type) {
    2057             :                 case OCI_STMT_SELECT:
    2058           2 :                         RETVAL_STRING("SELECT",1);
    2059           2 :                         break;
    2060             :                 case OCI_STMT_UPDATE:
    2061           2 :                         RETVAL_STRING("UPDATE",1);
    2062           2 :                         break;
    2063             :                 case OCI_STMT_DELETE:
    2064           2 :                         RETVAL_STRING("DELETE",1);
    2065           2 :                         break;
    2066             :                 case OCI_STMT_INSERT:
    2067           2 :                         RETVAL_STRING("INSERT",1);
    2068           2 :                         break;
    2069             :                 case OCI_STMT_CREATE:
    2070           4 :                         RETVAL_STRING("CREATE",1);
    2071           4 :                         break;
    2072             :                 case OCI_STMT_DROP:
    2073           2 :                         RETVAL_STRING("DROP",1);
    2074           2 :                         break;
    2075             :                 case OCI_STMT_ALTER:
    2076           2 :                         RETVAL_STRING("ALTER",1);
    2077           2 :                         break;
    2078             :                 case OCI_STMT_BEGIN:
    2079           2 :                         RETVAL_STRING("BEGIN",1);
    2080           2 :                         break;
    2081             :                 case OCI_STMT_DECLARE:
    2082           2 :                         RETVAL_STRING("DECLARE",1);
    2083           2 :                         break;
    2084             :                 case OCI_STMT_CALL:
    2085           2 :                         RETVAL_STRING("CALL",1);
    2086           2 :                         break;
    2087             :                 default:
    2088           4 :                         RETVAL_STRING("UNKNOWN",1);
    2089             :         }
    2090             : }
    2091             : /* }}} */
    2092             : 
    2093             : /* {{{ proto int oci_num_rows(resource stmt)
    2094             :    Return the row count of an OCI statement */
    2095          29 : PHP_FUNCTION(oci_num_rows)
    2096             : {
    2097             :         zval *z_statement;
    2098             :         php_oci_statement *statement;
    2099             :         ub4 rowcount;
    2100             : 
    2101          29 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &z_statement) == FAILURE) {
    2102           3 :                 return;
    2103             :         }
    2104             : 
    2105          26 :         PHP_OCI_ZVAL_TO_STATEMENT(z_statement, statement);
    2106             : 
    2107          26 :         if (php_oci_statement_get_numrows(statement, &rowcount TSRMLS_CC)) {
    2108           0 :                 RETURN_FALSE;
    2109             :         }
    2110          26 :         RETURN_LONG(rowcount);
    2111             : }
    2112             : /* }}} */
    2113             : 
    2114             : /* {{{ proto bool oci_free_collection()
    2115             :    Deletes collection object*/
    2116           5 : PHP_FUNCTION(oci_free_collection)
    2117             : {
    2118           5 :         zval **tmp, *z_collection = getThis();
    2119             :         php_oci_collection *collection;
    2120             : 
    2121           5 :         if (!getThis()) {
    2122           3 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &z_collection, oci_coll_class_entry_ptr) == FAILURE) {
    2123           1 :                         return;
    2124             :                 }       
    2125             :         }
    2126             :         
    2127           4 :         if (zend_hash_find(Z_OBJPROP_P(z_collection), "collection", sizeof("collection"), (void **)&tmp) == FAILURE) {
    2128           0 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find collection property");
    2129           0 :                 RETURN_FALSE;
    2130             :         }
    2131             :         
    2132           4 :         PHP_OCI_ZVAL_TO_COLLECTION(*tmp, collection);
    2133             : 
    2134           4 :         zend_list_delete(collection->id);
    2135           4 :         RETURN_TRUE;
    2136             : }
    2137             : /* }}} */
    2138             : 
    2139             : /* {{{ proto bool oci_collection_append(string value)
    2140             :    Append an object to the collection */
    2141          33 : PHP_FUNCTION(oci_collection_append)
    2142             : {
    2143          33 :         zval **tmp, *z_collection = getThis();
    2144             :         php_oci_collection *collection;
    2145             :         char *value;
    2146             :         int value_len;
    2147             : 
    2148          33 :         if (getThis()) {
    2149          20 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &value, &value_len) == FAILURE) {
    2150           0 :                         return;
    2151             :                 }
    2152             :         }
    2153             :         else {
    2154          13 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Os", &z_collection, oci_coll_class_entry_ptr, &value, &value_len) == FAILURE) {
    2155           1 :                         return;
    2156             :                 }       
    2157             :         }
    2158             :         
    2159          32 :         if (zend_hash_find(Z_OBJPROP_P(z_collection), "collection", sizeof("collection"), (void **)&tmp) == FAILURE) {
    2160           0 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find collection property");
    2161           0 :                 RETURN_FALSE;
    2162             :         }
    2163             :         
    2164          32 :         PHP_OCI_ZVAL_TO_COLLECTION(*tmp, collection);
    2165             : 
    2166          32 :         if (php_oci_collection_append(collection, value, value_len TSRMLS_CC)) {
    2167           4 :                 RETURN_FALSE;
    2168             :         }
    2169          28 :         RETURN_TRUE;
    2170             : }
    2171             : /* }}} */
    2172             : 
    2173             : /* {{{ proto string oci_collection_element_get(int ndx)
    2174             :    Retrieve the value at collection index ndx */
    2175          48 : PHP_FUNCTION(oci_collection_element_get)
    2176             : {
    2177          48 :         zval **tmp, *z_collection = getThis();
    2178             :         php_oci_collection *collection;
    2179             :         long element_index;
    2180             :         zval *value;
    2181             : 
    2182          48 :         if (getThis()) {
    2183          34 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &element_index) == FAILURE) {
    2184           0 :                         return;
    2185             :                 }
    2186             :         }
    2187             :         else {
    2188          14 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Ol", &z_collection, oci_coll_class_entry_ptr, &element_index) == FAILURE) {
    2189           1 :                         return;
    2190             :                 }       
    2191             :         }
    2192             :         
    2193          47 :         if (zend_hash_find(Z_OBJPROP_P(z_collection), "collection", sizeof("collection"), (void **)&tmp) == FAILURE) {
    2194           0 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find collection property");
    2195           0 :                 RETURN_FALSE;
    2196             :         }
    2197             :         
    2198          47 :         PHP_OCI_ZVAL_TO_COLLECTION(*tmp, collection);
    2199             : 
    2200          47 :         if (php_oci_collection_element_get(collection, element_index, &value TSRMLS_CC)) {
    2201          18 :                 RETURN_FALSE;
    2202             :         }
    2203             :         
    2204          29 :         *return_value = *value;
    2205          29 :         zval_copy_ctor(return_value);
    2206          29 :         zval_ptr_dtor(&value);
    2207             : }
    2208             : /* }}} */
    2209             : 
    2210             : /* {{{ proto bool oci_collection_assign(object from)
    2211             :    Assign a collection from another existing collection */
    2212          11 : PHP_FUNCTION(oci_collection_assign)
    2213             : {
    2214          11 :         zval **tmp_dest, **tmp_from, *z_collection_dest = getThis(), *z_collection_from;
    2215             :         php_oci_collection *collection_dest, *collection_from;
    2216             : 
    2217          11 :         if (getThis()) {
    2218           6 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &z_collection_from, oci_coll_class_entry_ptr) == FAILURE) {
    2219           0 :                         return;
    2220             :                 }
    2221             :         }
    2222             :         else {
    2223           5 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "OO", &z_collection_dest, oci_coll_class_entry_ptr, &z_collection_from, oci_coll_class_entry_ptr) == FAILURE) {
    2224           0 :                         return;
    2225             :                 }       
    2226             :         }
    2227             :         
    2228          11 :         if (zend_hash_find(Z_OBJPROP_P(z_collection_dest), "collection", sizeof("collection"), (void **)&tmp_dest) == FAILURE) {
    2229           0 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find collection property. The first argument should be valid collection object");
    2230           0 :                 RETURN_FALSE;
    2231             :         }
    2232             : 
    2233          11 :         if (zend_hash_find(Z_OBJPROP_P(z_collection_from), "collection", sizeof("collection"), (void **)&tmp_from) == FAILURE) {
    2234           0 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find collection property. The second argument should be valid collection object");
    2235           0 :                 RETURN_FALSE;
    2236             :         }
    2237             : 
    2238          11 :         PHP_OCI_ZVAL_TO_COLLECTION(*tmp_dest, collection_dest);
    2239          11 :         PHP_OCI_ZVAL_TO_COLLECTION(*tmp_from, collection_from);
    2240             : 
    2241          11 :         if (php_oci_collection_assign(collection_dest, collection_from TSRMLS_CC)) {
    2242           0 :                 RETURN_FALSE;
    2243             :         }
    2244          11 :         RETURN_TRUE;
    2245             : }
    2246             : /* }}} */
    2247             : 
    2248             : /* {{{ proto bool oci_collection_element_assign(int index, string val)
    2249             :    Assign element val to collection at index ndx */
    2250          21 : PHP_FUNCTION(oci_collection_element_assign)
    2251             : {
    2252          21 :         zval **tmp, *z_collection = getThis();
    2253             :         php_oci_collection *collection;
    2254             :         int value_len;
    2255             :         long element_index;
    2256             :         char *value;
    2257             : 
    2258          21 :         if (getThis()) {
    2259          13 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &element_index, &value, &value_len) == FAILURE) {
    2260           0 :                         return;
    2261             :                 }
    2262             :         }
    2263             :         else {
    2264           8 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Ols", &z_collection, oci_coll_class_entry_ptr, &element_index, &value, &value_len) == FAILURE) {
    2265           1 :                         return;
    2266             :                 }       
    2267             :         }
    2268             :         
    2269          20 :         if (zend_hash_find(Z_OBJPROP_P(z_collection), "collection", sizeof("collection"), (void **)&tmp) == FAILURE) {
    2270           0 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find collection property");
    2271           0 :                 RETURN_FALSE;
    2272             :         }
    2273             :         
    2274          20 :         PHP_OCI_ZVAL_TO_COLLECTION(*tmp, collection);
    2275             : 
    2276          20 :         if (php_oci_collection_element_set(collection, element_index, value, value_len TSRMLS_CC)) {
    2277           9 :                 RETURN_FALSE;
    2278             :         }
    2279          11 :         RETURN_TRUE;
    2280             : }
    2281             : /* }}} */
    2282             : 
    2283             : /* {{{ proto int oci_collection_size()
    2284             :    Return the size of a collection */
    2285           9 : PHP_FUNCTION(oci_collection_size)
    2286             : {
    2287           9 :         zval **tmp, *z_collection = getThis();
    2288             :         php_oci_collection *collection;
    2289           9 :         sb4 size = 0;
    2290             :         
    2291           9 :         if (!getThis()) {
    2292           4 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &z_collection, oci_coll_class_entry_ptr) == FAILURE) {
    2293           1 :                         return;
    2294             :                 }       
    2295             :         }
    2296             :         
    2297           8 :         if (zend_hash_find(Z_OBJPROP_P(z_collection), "collection", sizeof("collection"), (void **)&tmp) == FAILURE) {
    2298           0 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find collection property");
    2299           0 :                 RETURN_FALSE;
    2300             :         }
    2301             :         
    2302           8 :         PHP_OCI_ZVAL_TO_COLLECTION(*tmp, collection);
    2303             : 
    2304           4 :         if (php_oci_collection_size(collection, &size TSRMLS_CC)) {
    2305           0 :                 RETURN_FALSE;
    2306             :         }
    2307           4 :         RETURN_LONG(size);
    2308             : }
    2309             : /* }}} */
    2310             : 
    2311             : /* {{{ proto int oci_collection_max()
    2312             :    Return the max value of a collection. For a varray this is the maximum length of the array */
    2313           4 : PHP_FUNCTION(oci_collection_max)
    2314             : {
    2315           4 :         zval **tmp, *z_collection = getThis();
    2316             :         php_oci_collection *collection;
    2317             :         long max;
    2318             :         
    2319           4 :         if (!getThis()) {
    2320           2 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &z_collection, oci_coll_class_entry_ptr) == FAILURE) {
    2321           1 :                         return;
    2322             :                 }       
    2323             :         }
    2324             :         
    2325           3 :         if (zend_hash_find(Z_OBJPROP_P(z_collection), "collection", sizeof("collection"), (void **)&tmp) == FAILURE) {
    2326           0 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find collection property");
    2327           0 :                 RETURN_FALSE;
    2328             :         }
    2329             :         
    2330           3 :         PHP_OCI_ZVAL_TO_COLLECTION(*tmp, collection);
    2331             : 
    2332           3 :         if (php_oci_collection_max(collection, &max TSRMLS_CC)) {
    2333           0 :                 RETURN_FALSE;
    2334             :         }
    2335           3 :         RETURN_LONG(max);
    2336             : }
    2337             : /* }}} */
    2338             : 
    2339             : /* {{{ proto bool oci_collection_trim(int num)
    2340             :    Trim num elements from the end of a collection */
    2341          10 : PHP_FUNCTION(oci_collection_trim)
    2342             : {
    2343          10 :         zval **tmp, *z_collection = getThis();
    2344             :         php_oci_collection *collection;
    2345             :         long trim_size;
    2346             : 
    2347          10 :         if (getThis()) {
    2348           8 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &trim_size) == FAILURE) {
    2349           1 :                         return;
    2350             :                 }
    2351             :         }
    2352             :         else {
    2353           2 :                 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Ol", &z_collection, oci_coll_class_entry_ptr, &trim_size) == FAILURE) {
    2354           1 :                         return;
    2355             :                 }       
    2356             :         }
    2357             :         
    2358           8 :         if (zend_hash_find(Z_OBJPROP_P(z_collection), "collection", sizeof("collection"), (void **)&tmp) == FAILURE) {
    2359           0 :                 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find collection property");
    2360           0 :                 RETURN_FALSE;
    2361             :         }
    2362             :         
    2363           8 :         PHP_OCI_ZVAL_TO_COLLECTION(*tmp, collection);
    2364             : 
    2365           8 :         if (php_oci_collection_trim(collection, trim_size TSRMLS_CC)) {
    2366           3 :                 RETURN_FALSE;
    2367             :         }
    2368           5 :         RETURN_TRUE;    
    2369             : }
    2370             : /* }}} */
    2371             : 
    2372             : /* {{{ proto object oci_new_collection(resource connection, string tdo [, string schema])
    2373             :    Initialize a new collection */
    2374       70054 : PHP_FUNCTION(oci_new_collection)
    2375             : {
    2376             :         zval *z_connection;
    2377             :         php_oci_connection *connection;
    2378             :         php_oci_collection *collection;
    2379       70054 :         char *tdo, *schema = NULL;
    2380       70054 :         int tdo_len, schema_len = 0;
    2381             :         
    2382       70054 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|s", &z_connection, &tdo, &tdo_len, &schema, &schema_len) == FAILURE) {
    2383           1 :                 return;
    2384             :         }
    2385             :         
    2386       70053 :         PHP_OCI_ZVAL_TO_CONNECTION(z_connection, connection);
    2387             :         
    2388       70053 :         if ( (collection = php_oci_collection_create(connection, tdo, tdo_len, schema, schema_len TSRMLS_CC)) ) {
    2389       70047 :                 object_init_ex(return_value, oci_coll_class_entry_ptr);
    2390       70047 :                 add_property_resource(return_value, "collection", collection->id);
    2391             :         }
    2392             :         else {
    2393           6 :                 RETURN_FALSE;
    2394             :         }
    2395             : }
    2396             : /* }}} */
    2397             : 
    2398             : #endif /* HAVE_OCI8 */
    2399             : 
    2400             : /*
    2401             :  * Local variables:
    2402             :  * tab-width: 4
    2403             :  * c-basic-offset: 4
    2404             :  * End:
    2405             :  * vim600: noet sw=4 ts=4 fdm=marker
    2406             :  * vim<600: noet sw=4 ts=4
    2407             :  */

Generated by: LCOV version 1.10

Generated at Sun, 13 Jul 2014 23:57:52 +0000 (8 days ago)

Copyright © 2005-2014 The PHP Group
All rights reserved.