-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWPMetaUpdater.php
41 lines (32 loc) · 919 Bytes
/
WPMetaUpdater.php
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
32
33
34
35
36
37
38
39
40
41
<?php
class WPMetaUpdater
{
private $db_host = 'localhost';
private $db_user = 'root';
private $db_pass = '';
private $db_database = 'wordpress';
private $DBH;
function __construct()
{
try
{
$DBH = new PDO("mysql:host=$this->db_host;dbname=$this->db_database", $this->db_user, $this->db_pass);
$this->DBH = $DBH;
return $DBH;
}
catch (PDOException $e)
{
print "Error!: " . $e->getMessage() . "<br/>";
return false;
}
}
public function createStatement($id, $metaKey , $metaValue)
{
$this->DBH->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "INSERT INTO wp_usermeta (umeta_id,user_id,meta_key,meta_value) VALUES (NULL,:id,:metakey,:metavalue )";
$statement = $this->DBH->prepare($sql);
$statement->execute(array(':id' => $id , ':metakey' => $metaKey , 'metavalue' => $metaValue));
print_r($statement->errorCode());
}
}
?>