Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6860057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:21:39+00:00 2026-05-27T02:21:39+00:00

It has come down from high places that a webapp I’ve been working on

  • 0

It has come down from high places that a webapp I’ve been working on needs to move to stored procedures for everything it does in the database. To that end, I have taken to enforcing that constraint by writing a new database layer on top of mysqli which exposes only the “allowed” behavior. Consider what I have so far:

class Cas_Database
{
    private $mysqli;
    private $mode;

    public function __construct(...)
    {
    ... //Ommitted
    }

    public function Transaction(/* callable */ $func)
    {
        $mysqli->autocommit(false);
        try
        {
            $func($this);
            $mysqli->commit();
            $mysqli->autocommit(true);
        }
        catch (Exception $ex)
        {
            $mysqli->rollback();
            $mysqli->autocommit(true);
            throw $ex;
        }
    }

    public function MultiProcedure($schema, $func)
    {
        $args = func_num_args() - 2;
        $sql = "CALL `{$this->mode}_{$schema}`.`{$func}` (";
        if ($args >= 1)
        {
            $sql .= '? ';
            for ($idx = 1; $idx < $args; ++$idx)
            {
                $sql .= ', ?';
            }
        }
        $sql .= ')';
        $stmt = $mysqli->prepare($sql);
        $typeStr = '';
        $refArgs = array(null);
        for ($idx = 0; $idx < $args; ++$idx)
        {
            $argIndex = $idx + 2;
            $arg = func_get_arg($argIndex);
            $refArgs[] = &$arg;
            if (is_int($arg))
            {
                $typeStr .= 'i';
            }
            else if (is_float($arg))
            {
                $typeStr .= 'f';
            }
            else
            {
                $typeStr .= 's';
            }
        }
        $refArgs[0] = $typeStr;
        call_user_func_array(array($stmt, 'bind_param'), $refArgs);
        if ($stmt->execute() !== true)
        {
            $error = $stmt->error;
            $stmt->close();
            throw new Exception($error);
        }
        $mysqlAnswer = $stmt->get_result();
        $results = array();
        while (($answerRow = $mysqlAnswer->fetch_assoc()) !== null)
        {
            $results[] = $answerRow;
        }
        $stmt->close();
        return $results;
    }
}

Note how the MultiProcedure function expects multiple arguments from the user. Is there a way to specify that in the contract of the function so that users know what to look for, or are they forced to read the method to find out?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T02:21:40+00:00Added an answer on May 27, 2026 at 2:21 am

    Use phpDocumentor’s @param syntax to mention it in the documentation of the method. It will show up when you generate the docs, and in the developer’s IDE at the time the method will be used.

    Write the parameter name as $paramn,... and in the description write that there can be any number of arguments.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a data frame in R that has come about from running some
A new requirement has come down from the top: implement 'proprietary business tech' with
I'm currently working on the internationalization of a product and an issue has come
New to stackoverflow, been very helpful searching, but alas the time has come to
I'm writing an app for android that needs to parse data from an XML
We have an InfoPath 2007 form that populates a drop down from a SharePoint
This is a bit of a hypothetical question that has sent me off down
Programming has come a long way. I am still relatively young (first Computer: C64),
My boss has come to me and asked how to enure a file uploaded
I know this questions has come up in various guises before, but this is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.