Ejemplo n.º 1
0
        /// <summary>
        /// Gets a PHP object whose properties describes a specified field.
        /// </summary>
        /// <param name="resultHandle">Query result resource.</param>
        /// <param name="fieldIndex">Field index.</param>
        /// <returns>The PHP object.</returns>
        public static stdClass mssql_fetch_field(PhpResource resultHandle, int fieldIndex = -1)
        {
            PhpSqlDbResult result = PhpSqlDbResult.ValidResult(resultHandle);

            if (result == null)
            {
                return(null);
            }

            if (fieldIndex < 0)
            {
                fieldIndex = result.FetchNextField();
            }

            //DataRow info = result.GetSchemaRowInfo(fieldIndex);
            //if (info == null) return null;
            //string s;

            string php_type = result.GetPhpFieldType(fieldIndex);

            var arr = new PhpArray(5);

            arr.Add("name", result.GetFieldName(fieldIndex));
            //arr.Add("column_source", (s = info["BaseColumnName"] as string) != null ? s : ""); // TODO: column_source
            arr.Add("max_length", result.GetFieldLength(fieldIndex));
            arr.Add("numeric", result.IsNumericType(php_type) ? 1 : 0);
            arr.Add("type", php_type);

            return((stdClass)arr.ToClass());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets a length of a specified column (field) in a result.
        /// </summary>
        /// <param name="resultHandle">Query result resource.</param>
        /// <param name="fieldIndex">Column index.</param>
        /// <returns>Length of the column or a -1 on failure (invalid resource or column index).</returns>
        public static int mssql_field_length(PhpResource resultHandle, int fieldIndex)
        {
            PhpSqlDbResult result = PhpSqlDbResult.ValidResult(resultHandle);

            if (result == null)
            {
                return(-1);
            }

            return(result.GetFieldLength(fieldIndex));
        }