本文整理汇总了PHP中Zend_Db_Table::insert方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Db_Table::insert方法的具体用法?PHP Zend_Db_Table::insert怎么用?PHP Zend_Db_Table::insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Db_Table
的用法示例。
在下文中一共展示了Zend_Db_Table::insert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: insert
public function insert(array $data)
{
$this->_db = CrFramework_Db_Control::getAdapter('write');
$this->setDefaultAdapter($this->_db);
//logStd(get_class($this).'->createRow()', 'Write to MASTER:'.$id);
return parent::insert($data);
}
示例2: insert
public function insert($data)
{
if (empty($data['nazwa']) && empty($data['producent']) && empty($data['termin_licencji']) && empty($data['numer_seryjny'])) {
throw new Soft_Validation_Exception('Zadne pole wymagane nie zostalo wypelnione!!!');
}
if (empty($data['nazwa'])) {
throw new Soft_Validation_Exception('Nie podales nazwy oprogramowania! Pole wymagane!!!');
}
if (empty($data['producent'])) {
throw new Soft_Validation_Exception('Nie podales producenta oprogramowania! Pole wymagane!!!');
}
if (empty($data['nr_seryjny'])) {
throw new Soft_Validation_Exception('Nie podales nmeru seryjnego! Pole wymagane!!!');
}
if (empty($data['termin_licencji'])) {
throw new Soft_Validation_Exception('Nie podales terminu licencji! Pole wymagane!!!');
}
if (empty($data['termin_licencji'])) {
throw new Soft_Validation_Exception('Nie podales terminu licencji! Pole wymagane!!!');
}
if (!eregi('[0-9]', $data['ilosc_stanowisk'])) {
throw new Soft_Validation_Exception('Niepoprawna liczba stanowisk!');
}
if (!eregi('[0-9-]', $data['termin_licencji'])) {
throw new Soft_Validation_Exception('Niepoprawna data!');
}
return parent::insert($data);
}
示例3: save
/**
* Saves the properties to the database.
*
* This performs an intelligent insert/update, and reloads the
* properties with fresh data from the table on success.
*
* @return int 0 on failure, 1 on success.
*/
public function save()
{
// convenience var for the primary key name
$primary = $this->_info['primary'];
// check the primary key value for insert/update
if (empty($this->_data[$primary])) {
// no primary key value, must be an insert.
// make sure it's null.
$this->_data[$primary] = null;
// attempt the insert.
$result = $this->_table->insert($this->_data);
if (is_numeric($result)) {
// insert worked, refresh with data from the table
$this->_data[$primary] = $result;
$this->_refresh();
}
// regardless of success return the result
return $result;
} else {
// has a primary key value, update only that key.
$where = $this->_db->quoteInto("{$primary} = ?", $this->_data[$primary]);
// return the result of the update attempt,
// no need to update the row object.
$result = $this->_table->update($this->_data, $where);
if (is_int($result)) {
// update worked, refresh with data from the table
$this->_refresh();
}
}
}
示例4: insert
public function insert($data)
{
if (!$this->ifLogin($data['login'])) {
throw new User_Validation_Exception('Podany login istnieje juz w bazie danych! Wybierz inny.');
}
if (empty($data['login']) && empty($data['haslo'])) {
throw new User_Validation_Exception('Nie podales loginu ani hasla!');
}
if (empty($data['login'])) {
throw new User_Validation_Exception('Nie podales loginu!');
}
if (strlen($data['login']) < 5) {
throw new User_Validation_Exception('Login musi skladac sie z co najmniej 5 znakow!');
}
if (empty($data['haslo'])) {
throw new User_Validation_Exception('Nie podales hasla!');
}
if (strlen($data['haslo']) < 5) {
throw new User_Validation_Exception('Haslo musi skladac sie z co najmniej 5 znakow!');
}
if (!eregi('^[a-zA-z]', $data['login'])) {
throw new User_Validation_Exception('Login musi zaczynac sie od litery!');
}
return parent::insert($data);
}
示例5: insert
/**
* Inserts a new row.
*
* @param array $data Column-value pairs.
* @return mixed The primary key of the row inserted.
*/
public function insert(array $data)
{
$rowMaxSort = $this->fetchRow($this->select()->order('sort DESC'));
$maxSort = $rowMaxSort ? (int) $rowMaxSort->sort + 1 : 1;
$data['sort'] = $maxSort;
return parent::insert($data);
}
示例6: add
/**
* Add new setting and return ID of the setting
*/
public function add($setting, $table)
{
global $logger;
$oTable = new Zend_Db_Table($table);
$data = array('name' => $setting->name);
$result = $oTable->insert($data);
$logger->log("Add setting {$table}={$setting->name}", Zend_Log::INFO);
return $result;
}
示例7: insert
public function insert(array $data)
{
if (empty($data['created_at'])) {
$data['created_at'] = date('Y-m-d h:i:s');
}
if (empty($data['updated_at'])) {
$data['updated_at'] = date('Y-m-d h:i:s');
}
return parent::insert($data);
}
示例8: createMessage
/**
* Create a new message in an existing thread
*
* @param array $data
* @return $id
*/
public function createMessage(array $data)
{
$messages_table = new Zend_Db_Table('messages');
$data['date_created'] = date('Y-m-d H:i:s');
$messages_table->insert($data);
$threads_table = new Zend_Db_Table('threads');
$thread_data = array('unread' => new Zend_Db_Expr('unread + 1'), 'deleted_from' => 0, 'deleted_to' => 0, 'last_speaker' => $data['user_from']);
$where = array('id = ?' => $data['thread_id']);
$threads_table->update($thread_data, $where);
}
示例9: insert
public function insert(&$data)
{
if (empty($data['nazwa'])) {
throw new Hamster_Validation_Exception('Podaj nazwę ankiety.');
}
if (strlen($data['nazwa']) < 6) {
throw new Hamster_Validation_Exception('Nazwa ankiety musi miec conamniej 6 znaków.');
}
return parent::insert($data);
}
示例10: formAction
public function formAction()
{
$table = new Zend_Db_Table();
$table->setOptions(array('name' => 'test'));
$table->setMetadataCacheInClass(true);
$data = array('listorder' => '11');
$table->insert($data);
Zend_Debug::dump($table);
die;
}
示例11: setup
/**
* (non-PHPdoc)
* @see models/Sahara/Auth/Sahara_Auth_Session::setup()
*/
public function setup()
{
$table = new Zend_Db_Table('users');
$record = $table->fetchRow($table->select()->where('name = ?', $this->_authType->getUsername())->where('namespace = ?', $this->_config->institution));
/* User name exists, so no need to create account. */
if ($record) {
return;
}
$table->insert(array('name' => $this->_authType->getUsername(), 'namespace' => $this->_config->institution, 'persona' => 'USER'));
}
示例12: save
/**
* Save a new entry
* @param array $data
* @return int|string
*/
public function save(array $data)
{
$table = new Zend_Db_Table('users');
$fields = $table->info(Zend_Db_Table_Abstract::COLS);
foreach ($data as $field => $value) {
if (!in_array($field, $fields)) {
unset($data[$field]);
}
}
return $table->insert($data);
}
示例13: addUser
/**
* Register new user with given $id and $password
* Returns true in case of success and false if user with given $id already
* exists
*
* @param string $id user identity URL
* @param string $password encoded user password
* @return bool
*/
public function addUser($id, $password)
{
// escaping not required as values are inserted as parameters
$user = array('username' => $id, 'password' => $password, 'created' => date('Y-m-d H:i:s'), 'openid' => Zend_OpenId::absoluteURL('/openid/' . $id));
if ($this->hasUser($id)) {
return false;
} else {
$this->_usersTable->insert($user);
}
return true;
}
示例14: save
/**
* Save object in DB
*
* @return HumanHelp_Model_Comment
*/
public function save()
{
$table = new Zend_Db_Table('comments');
if (isset($this->_id)) {
// Update
$table->update($this->_data, $table->getAdapter()->quoteInto('id = ?', $this->_id));
} else {
// Insert
$table->insert($this->_data);
$this->_id = $table->getAdapter()->lastInsertId('comments', 'id');
}
return $this;
}
示例15: addAction
public function addAction()
{
$form = new Application_Model_ContactForm(array('action' => '/contact/add', 'method' => 'POST'));
if ($this->getRequest()->isPost()) {
if ($form->isValid($this->getRequest()->getPost())) {
$contact = new Zend_Db_Table('contacts');
$data = array('name' => $this->_request->getPost('name'), 'email' => $this->_request->getPost('email'), 'type' => $this->_request->getPost('type'));
$contact->insert($data);
echo "<p>Contact added!</p>";
}
}
$this->view->form = $form;
}