views:

153

answers:

5

IS this bit of code in PHP/mysql considered a stored procedure?

$sql = 'SELECT username FROM user WHERE username = ? AND passwordHash = ?';
$result = $db->query($sql, array($_POST['username'], $passwordHash));
+1  A: 

No. It's just a simple execution of SQL on a database. No stored procedure or method call.

Kosi2801
+4  A: 

No. It's just a query. The fact that is hard-coded in something else (in this case, PHP) does not make it a stored procedure.

A stored procedure is stored inside the database. See also the manual on stored routines

Martijn
+1  A: 

A stored procedure is a piece of SQL that is stored on the SQL server.

Like wikipedia describes it :

A stored procedure is a subroutine available to applications accessing a relational database system.

Stored procedures (sometimes called a proc, sproc, StoPro, or SP) are actually stored in the database data dictionary.

If you are working with a MySQL database, you might want to take a look at this section of the manual : Chapter 19. Stored Programs and Views


Here, your SQL code is not stored on the SQL server : it is written directly in your PHP script.

So, no, this is not a stored procedure -- it's a simple SQL query.

Pascal MARTIN
A: 

Not that I can see.

This is simply a SQL Select statement with parameters.

MySQL reference on stored routines

http://dev.mysql.com/doc/refman/5.1/en/stored-routines.html

Jaydee
A: 

It's not. Stored procedures looks like this:

 CREATE PROCEDURE simpleproc (OUT param1 INT)
 BEGIN
   SELECT COUNT(*) INTO param1 FROM t;
 END

(from mysql documentation)

Thinker