项目作者: g--o

项目描述 :
Prepared Statements wrapper
高级语言: PHP
项目地址: git://github.com/g--o/Stmt.git
创建时间: 2016-09-30T12:43:05Z
项目社区:https://github.com/g--o/Stmt

开源协议:GNU General Public License v3.0

下载


Stmt

Prepared Statements wrapper for php.
Now you can use prepared statements just like a normal query.

Example

Let’s say for example a user tries to find another user by email.
We store it’s requested email and filter it.
We store the result in the varaible $email.

We make a mysqli object and store it in $con.

One way to fetch our reuqested username would be:

  1. $stmt = new Stmt($con, "SELECT * FROM ".USERS_TABLE." WHERE email=?", array(&$email)) or die($this->con->error);
  2. // check for result
  3. if ($stmt->getNumRows() > 0) {
  4. $result = $stmt->fetchRow();
  5. $username = $result['username'];
  6. }
  7. ...

Just like a usual query.