5 posts
|
Hi guys,
I’m looking for a way to get the mysql/pdo conenctor on a frontend page to insert some data in a table, by exemple:
function save_data($data1, $data2) {
global $__CONN__;
$sql = ‘INSERT INTO my_table (data1, data2)) VALUES ( ?, ?)’;
$stmt = $__CONN__->prepare($sql);
$stmt->execute(array($data1, $data2)));
}
Is there a way to have it works ?
Thanks a lot. |
5 posts
|
Btw I made it works with
require_once(FROG_ROOT.’/config.php’);
$dbh = new PDO;
$sql = ‘insert into mytable
(title, last_name, first_name, email)
values
(:title, :last_name, :first_name, :email)’;
$stmt = $dbh->prepare($sql);
$insert_ary = array(
‘title’ => $values[‘title’],
‘last_name’ => $values[‘last_name’],
‘first_name’ => $values[‘first_name’],
‘email’ => $values[‘email’]);
return $stmt->execute($insert_ary);
Comments or suggestions are welcome. |