GMgKe586q6suSQnyqZLlGCooeWM

Pages

Search

Sunday, April 10, 2011

Zend - Inserting Data To Database

user require_once to include
Zend/Db/Adapter/Pdo/Mysql.php

Then use this code on function
$params = array(
    'host' => 'localhost',
    'username' => 'root',
    'password' => 'pass',
    'dbname' => 'zend',
);
$db = new Zend_Db_Adapter_Pdo_Mysql($params);
$data = array(
    'name' => 'Lady Gaga',
    'city' => 'New York',
    'age' => 45,
);
$db->insert('table', $data);
$result = $db->fetchAssoc('SELECT * FROM table');

Share/Bookmark

No comments:

Post a Comment