Skip to content

Commit 79bf0de

Browse files
committed
Update README.md
1 parent bb39632 commit 79bf0de

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -238,37 +238,37 @@ $db->query("users.count(*).as(users_nb).group(activated)");
238238
try {
239239
$jsondb = new \JSONDB\JSONDB();
240240

241-
if (!file_exists('./test') {
241+
if (!file_exists('./test')) {
242242
$jsondb->createServer('./test', 'root', '');
243243
}
244244

245245
$db = $jsondb->connect('./test', 'root', '')
246-
->createDatabase('test_database')
247-
->setDatabase('test_database'); // Yes, is chainable ! ;-)
246+
->createDatabase('test_database')
247+
->setDatabase('test_database'); // Yes, is chainable ! ;-)
248248

249249
$db->createTable('users', array('id' => array('type' => 'int', 'auto_increment' => TRUE),
250-
'name' => array('type' => 'string', 'max_length' => 30, 'not_null' => TRUE),
251-
'surname' => array('type' => 'string', 'max_length' => 30, 'not_null' => TRUE),
252-
'pseudo' => array('type' => 'string', 'max_length' => 15, 'unique_key' => TRUE),
253-
'mail' => array('type' => 'string', 'unique_key' => TRUE),
254-
'password' => array('type' => 'string', 'not_null' => TRUE),
255-
'website' => array('type' => 'string'),
256-
'activated' => array('type' => 'bool', default => false),
257-
'banished' => array('type' => 'bool', default => false)));
250+
'name' => array('type' => 'string', 'max_length' => 30, 'not_null' => TRUE),
251+
'surname' => array('type' => 'string', 'max_length' => 30, 'not_null' => TRUE),
252+
'pseudo' => array('type' => 'string', 'max_length' => 15, 'unique_key' => TRUE),
253+
'mail' => array('type' => 'string', 'unique_key' => TRUE),
254+
'password' => array('type' => 'string', 'not_null' => TRUE),
255+
'website' => array('type' => 'string'),
256+
'activated' => array('type' => 'bool', 'default' => false),
257+
'banished' => array('type' => 'bool', 'default' => false)));
258258

259259
// A prepared query
260-
$query = $db->prepare('users.insert(:name, :sname, :pseudo, :mail, :pass).in(name, surname, pseudo, mail, pass)');
260+
$query = $db->prepare('users.insert(:name, :sname, :pseudo, :mail, :pass).in(name, surname, pseudo, mail, password)');
261261
$query->bindValue(':name', 'Nana', \JSONDB\JSONDB::PARAM_STRING);
262262
$query->bindValue(':sname', 'Axel', \JSONDB\JSONDB::PARAM_STRING);
263263
$query->bindValue(':pseudo', 'na2axl', \JSONDB\JSONDB::PARAM_STRING);
264264
$query->bindValue(':mail', '[email protected]', \JSONDB\JSONDB::PARAM_STRING);
265265
$query->bindValue(':pass', $password, \JSONDB\JSONDB::PARAM_STRING);
266266
$query->execute();
267-
267+
268268
// After some insertions...
269-
269+
270270
// Select all users
271-
$results = $db->query("users.select(id, name, surname, pseudo)");
271+
$results = $db->query('users.select(id, name, surname, pseudo)');
272272
// Fetch as object
273273
while ($result = $results->fetch(\JSONDB\JSONDB::FETCH_OBJECT)) {
274274
echo "The user with id: {$result->id} has the name: {$result->name} {$result->surname} and the pseudo: {$result->pseudo}.\n";

0 commit comments

Comments
 (0)