-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.php
More file actions
31 lines (22 loc) · 778 Bytes
/
Copy pathexample.php
File metadata and controls
31 lines (22 loc) · 778 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
define('MYSQL_HOST', 'localhost');
define('MYSQL_USER', 'root');
define('MYSQL_PASS', 'mypassword');
define('MYSQL_DB', 'testdb');
require_once('PDO.php');
$sql = new PDOWrapper(MYSQL_HOST, MYSQL_USER, MYSQL_PASS, MYSQL_DB);
/* Delete ID 1 from users */
$sql->query("DELETE FROM users WHERE id = 1")
/* Select ID from users if user is admin */
$sql->fetch_array("SELECT id FROM users WHERE user = 'admin'");
/* Insert data database */
$sql->insert('test', ['id' => 10, 'name' => 'Paulo', 'age' => '18'])
/* Search my name Paulo in the table test */
$sql->search('test', ['name', 'Paulo'])
/* Count total of rows in table */
$sql->rowCount("users")
/* Count total of tables in the database */
$sql->tablesCount()
/* Get last inserted id */
$sql->lastInsertId()
?>