Example #1
0
        public static bool Bind(PhpResource statement, string parameterName, PhpReference variable, VariableType type,
                                bool isOutput, bool isNullable, int maxLength)
        {
            PhpSqlDbProcedure procedure = PhpSqlDbProcedure.ValidProcedure(statement);

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

            if (parameterName == null)
            {
                PhpException.ArgumentNull("parameterName");
                return(false);
            }

            PhpSqlDbProcedure.ParameterType param_type = PhpSqlDbProcedure.VariableTypeToParamType(type);
            if (param_type == PhpSqlDbProcedure.ParameterType.Invalid)
            {
                PhpException.ArgumentValueNotSupported("type", (int)type);
                return(false);
            }

            SqlParameter parameter = new SqlParameter();

            parameter.ParameterName = parameterName;

            // it is necessary to set size for in-out params as the results are truncated to this size;
            // 8000 is maximal size of the data according to the doc:
            if (maxLength >= 0)
            {
                parameter.Size = maxLength;
            }
            else
            {
                parameter.Size = 8000;
            }

            if (String.Compare(parameterName, "RETVAL", true) == 0)
            {
                parameter.Direction = ParameterDirection.ReturnValue;
            }
            else if (isOutput)
            {
                parameter.Direction = ParameterDirection.InputOutput;
            }
            else
            {
                parameter.Direction = ParameterDirection.Input;
            }

            if (!procedure.AddBinding(parameter, variable, param_type))
            {
                PhpException.Throw(PhpError.Notice, LibResources.GetString("parameter_already_bound", parameterName));
                return(false);
            }

            return(true);
        }
Example #2
0
        public static bool FreeStatement(PhpResource statement)
        {
            PhpSqlDbProcedure procedure = PhpSqlDbProcedure.ValidProcedure(statement);

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

            procedure.Close();
            return(true);
        }
Example #3
0
        internal static PhpSqlDbProcedure ValidProcedure(PhpResource handle)
        {
            PhpSqlDbProcedure result = handle as PhpSqlDbProcedure;

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

            PhpException.Throw(PhpError.Warning, LibResources.GetString("invalid_stored_procedure_resource"));
            return(null);
        }
Example #4
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);
        }