0

Is it possible to get the query that it's being tried to be executed on PHP?

Here is the code i'm trying:

public static function executeInsertQuery($sqlQuery)
{
    $dbTable = mysql_query($sqlQuery, self::$_dbLink);

    if($dbTable === false){
        Models_Error::throwException("Connection to table failed.", 'database');
    }

    return null;
}

How can I validate that to be always an Insert into query?

1 Answer 1

1

Don't rely on being passed a query.

In my current project, if I want to insert something, it looks like this:

DB::insert("tablename",array(
    "column" => "value",
    "col2"   => "val2",
    "foo"    => "bar"
));

This is then translated into a proper query (using PDO in this case, but that doesn't matter here)

Sign up to request clarification or add additional context in comments.

2 Comments

thanks! I will try it that way, but anyways I'm interested in the validation process.
I mean, it's absolutely better defining the functions so, that it's clear the function, but I find really interesting the validation process of large strings

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.