Commit c5a12be0 authored by Alexander Butenko's avatar Alexander Butenko

Merge remote-tracking branch 'upstream/master'

Conflicts:
	MysqliDb.php
parents bbd80bc5 ef942d6b
......@@ -363,6 +363,20 @@ class MysqliDb
return true;
}
/**
* A convenient function that returns TRUE if exists at least an element that
* satisfy the where condition specified calling the "where" method before this one.
*
* @param string $tableName The name of the database table to work with.
*
* @return array Contains the returned rows from the select query.
*/
public function has($tableName)
{
$this->getOne($tableName, '1');
return $this->count >= 1;
}
/**
* Update query. Be sure to first call the "where" method.
*
......@@ -1153,3 +1167,4 @@ class MysqliDb
$this->rollback ();
}
} // END class
?>
......@@ -14,7 +14,8 @@ MysqliDb -- Simple MySQLi wrapper with prepared statements
**[Properties Sharing](#properties-sharing)**
**[Joining Tables](#join-method)**
**[Subqueries](#subqueries)**
**[EXISTS / NOT EXISTS condition](#exists--not-exists-condition)**
**[EXISTS / NOT EXISTS condition](#exists--not-exists-condition)**
**[Has method](#has-method)**
**[Helper Functions](#helper-commands)**
**[Transaction Helpers](#transaction-helpers)**
......@@ -393,6 +394,18 @@ $products = $db->get ("products");
// Gives SELECT * FROM products WHERE EXISTS (select userId from users where company='testCompany')
```
### Has method
A convenient function that returns TRUE if exists at least an element that satisfy the where condition specified calling the "where" method before this one.
```php
$db->where("user", $user);
$db->where("password", md5($password));
if($db->has("users")) {
return "You are logged";
} else {
return "Wrong user/password";
}
```
### Helper commands
Reconnect in case mysql connection died
```php
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment