Exemplo n.º 1
0
        public static object GetField(PhpResource resultHandle, int rowIndex, object field)
        {
            PhpSqlDbResult result = PhpSqlDbResult.ValidResult(resultHandle);

            ScriptContext context = ScriptContext.CurrentContext;

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

            string field_name;
            object field_value;

            if (field == null)
            {
                field_value = result.GetFieldValue(rowIndex, result.CurrentFieldIndex);
            }
            else if ((field_name = PhpVariable.AsString(field)) != null)
            {
                field_value = result.GetFieldValue(rowIndex, field_name);
            }
            else
            {
                field_value = result.GetFieldValue(rowIndex, Core.Convert.ObjectToInteger(field));
            }

            return(Core.Convert.Quote(field_value, context));
        }
Exemplo n.º 2
0
        public static string FieldType(PhpResource resultHandle, int fieldIndex)
        {
            PhpSqlDbResult result = PhpSqlDbResult.ValidResult(resultHandle);

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

            return(result.GetPhpFieldType(fieldIndex));
        }
Exemplo n.º 3
0
        public static string FieldName(PhpResource resultHandle)
        {
            PhpSqlDbResult result = PhpSqlDbResult.ValidResult(resultHandle);

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

            return(result.GetFieldName());
        }
Exemplo n.º 4
0
        public static bool FieldSeek(PhpResource resultHandle, int fieldOffset)
        {
            PhpSqlDbResult result = PhpSqlDbResult.ValidResult(resultHandle);

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

            return(result.SeekField(fieldOffset));
        }
Exemplo n.º 5
0
        public static int GetRowCount(PhpResource resultHandle)
        {
            PhpSqlDbResult result = PhpSqlDbResult.ValidResult(resultHandle);

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

            return(result.RowCount);
        }
Exemplo n.º 6
0
        public static bool DataSeek(PhpResource resultHandle, int rowIndex)
        {
            PhpSqlDbResult result = PhpSqlDbResult.ValidResult(resultHandle);

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

            return(result.SeekRow(rowIndex));
        }
Exemplo n.º 7
0
        public static PhpObject FetchObject(PhpResource resultHandle)
        {
            PhpSqlDbResult result = PhpSqlDbResult.ValidResult(resultHandle);

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

            return(result.FetchObject());
        }
Exemplo n.º 8
0
        public static PhpObject FetchField(PhpResource resultHandle, int fieldIndex)
        {
            PhpSqlDbResult result = PhpSqlDbResult.ValidResult(resultHandle);

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

            return(FetchFieldInternal(result, fieldIndex));
        }
Exemplo n.º 9
0
        public static int FieldLength(PhpResource resultHandle, int fieldIndex)
        {
            PhpSqlDbResult result = PhpSqlDbResult.ValidResult(resultHandle);

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

            return(result.GetFieldLength(fieldIndex));
        }
Exemplo n.º 10
0
        public static bool NextResult(PhpResource resultHandle)
        {
            PhpSqlDbResult result = PhpSqlDbResult.ValidResult(resultHandle);

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

            return(result.NextResultSet());
        }
Exemplo n.º 11
0
        public static bool FreeResult(PhpResource resultHandle)
        {
            PhpSqlDbResult result = PhpSqlDbResult.ValidResult(resultHandle);

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

            result.Close();
            return(true);
        }
Exemplo n.º 12
0
        internal static PhpSqlDbResult ValidResult(PhpResource handle)
        {
            PhpSqlDbResult result = handle as PhpSqlDbResult;

            if (result != null && result.IsValid)
            {
                return(result);
            }

            PhpException.Throw(PhpError.Warning, LibResources.GetString("invalid_result_resource"));
            return(null);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Executes the procedure.
        /// </summary>
        /// <param name="skipResults">Whether to load the results.</param>
        /// <param name="success">Whether the execution succeeded.</param>
        /// <returns>Results or a <B>null</B> reference if results are not loaded or an error occured.</returns>
        public PhpSqlDbResult Execute(bool skipResults, out bool success)
        {
            PhpSqlDbResult result = (PhpSqlDbResult)connection.ExecuteProcedure(procedureName,
                                                                                PrepareParameters(), skipResults);

            success = connection.LastException == null;

            if (success)
            {
                WriteParametersBack();
            }

            return(result);
        }
Exemplo n.º 14
0
        public static PhpResource Query(string query, PhpResource linkIdentifier, int batchSize)
        {
            PhpSqlDbConnection connection = PhpSqlDbConnection.ValidConnection(linkIdentifier);

            if (query == null || connection == null)
            {
                return(null);
            }

            PhpSqlDbResult result = (PhpSqlDbResult)connection.ExecuteQuery(query.Trim(), true);

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

            result.BatchSize = batchSize;
            return(result);
        }
Exemplo n.º 15
0
        public static PhpArray FetchArray(PhpResource resultHandle, QueryResultKeys resultType)
        {
            PhpSqlDbResult result = PhpSqlDbResult.ValidResult(resultHandle);

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

            switch (resultType)
            {
            case QueryResultKeys.ColumnNames: return(result.FetchArray(false, true));

            case QueryResultKeys.Numbers: return(result.FetchArray(true, false));

            case QueryResultKeys.Both: return(result.FetchArray(true, true));
            }

            return(null);
        }
Exemplo n.º 16
0
        private static PhpObject FetchFieldInternal(PhpSqlDbResult /*!*/ result, int fieldIndex)
        {
            DataRow info = result.GetSchemaRowInfo(fieldIndex);

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

            string    s;
            PhpObject obj      = new stdClass();
            string    php_type = result.GetPhpFieldType(fieldIndex);

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

            return(obj);
        }
Exemplo n.º 17
0
        public static object Execute(PhpResource statement, bool skipResults)
        {
            PhpSqlDbProcedure procedure = PhpSqlDbProcedure.ValidProcedure(statement);

            if (procedure == null)
            {
                return(false);
            }

            bool           success;
            PhpSqlDbResult result = procedure.Execute(skipResults, out success);

            if (!success)
            {
                return(false);
            }
            if (skipResults)
            {
                return(true);
            }
            return(result);
        }
Exemplo n.º 18
0
		private static PhpObject FetchFieldInternal(PhpSqlDbResult/*!*/ result, int fieldIndex)
		{
			DataRow info = result.GetSchemaRowInfo(fieldIndex);
			if (info == null) return null;

			string s;
			PhpObject obj = new stdClass();
			string php_type = result.GetPhpFieldType(fieldIndex);

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

			return obj;
		}