1

I am unable to understand what does the query() function actually returns? The comments in functions.php say that it returns all row in result set. Please somebody explain to me what do the following function call returns?

query("SELECT * FROM users WHERE username = ?", $_POST["username"]);

1 Answer 1

3

The function named query() returns an array of row where each element in that array is another associative array that forms a row.

When the following statement is executed, considering that username is a primary key,

query("SELECT * FROM users WHERE username = ?", $_POST["username"]);

and if there's a matching row in the database, query() should return something like

Array
(
    [0] => Array
        (
            [username] => kareem
            [name] => Google Inc.
            [symbol] => GOOG
            [shares] => 1
        )
)

The contents of the inner associated array may differ depending on the columns of your row(s) in your database.

You may use the function named dump() to print the value that query() returns.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .