本文整理匯總了PHP中type::insert方法的典型用法代碼示例。如果您正苦於以下問題:PHP type::insert方法的具體用法?PHP type::insert怎麽用?PHP type::insert使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類type
的用法示例。
在下文中一共展示了type::insert方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: gravar
/**
*
* @param array $data
* @throws Exception
*/
public function gravar(array $data)
{
try {
$this->_modelNotificacao->insert($data);
} catch (Exception $ex) {
throw new Exception($ex->getMessage());
}
}
示例2: insert
/**
* 保存數據
* @param array $entity 有屬性名和所要插入的屬性值組成的一維數組或二維數組,如:$parameter = array('shopName'=>'kongfz','userId'=>1)
* @param string $table 表名
* @param boolean $isReturnLastInsertId true:獲取插入記錄自增id,false:不返回插入記錄自增id
* @param int $dimension 參數$parameter維度 1:插入一條數據,2:插入多條數據
* @return boolean or int
*/
public function insert(array $entity, $table = '', $isReturnLastInsertId = true, $dimension = 1)
{
if (is_null($this->db)) {
$this->db = \Util\Db\Manager::getInstance($this->dbName);
}
//如果方法中沒傳遞表名,則向默認表中插入數據
$table = is_string($table) && $table != '' ? $table : $this->defaultTable;
$state = $this->db->insert($entity, $table, $dimension);
if ($isReturnLastInsertId && $state) {
return $this->db->getLastInsertId();
}
return $state;
}
示例3: saveArtist
/**
*
* @param \Music\Model\Artist $artist
* @throws \Exception
*/
public function saveArtist(Artist $artist)
{
$data = array('full_name' => $artist->getFullName(), 'year_found' => $artist->getYearFound(), 'origin' => $artist->getOrigin(), 'createdby' => $this->id);
$artist_id = (int) $artist->getArtistId();
if ($artist_id == 0) {
$this->tableGateway->insert($data);
} else {
if ($this->getArtist($artist_id)) {
//\Zend\Debug\Debug::dump($artist_id);
$this->tableGateway->update($data, array('artist_id' => $artist_id));
} else {
throw new \Exception('Form id does not exist');
}
}
}
示例4: insertContactData
/**
* Insert a row in contact table
* @param type $data
* @return boolean
*/
public function insertContactData($data)
{
try {
$this->tableGateway->insert($data);
return true;
} catch (Exception $e) {
return false;
}
}
示例5: save
/**
* Save
*
* @return integer
*/
public function save()
{
if (is_array($this->primaryKey)) {
// @todo compound primary keys
}
if (isset($this->originalData[$this->primaryKey])) {
// UPDATE
$where = array($this->primaryKey => $this->originalData[$this->primaryKey]);
$data = $this->currentData;
unset($data[$this->primaryKey]);
$rowsAffected = $this->tableGateway->update($data, $where);
} else {
// INSERT
$rowsAffected = $this->tableGateway->insert($this->currentData);
$primaryKey = $this->tableGateway->getLastInsertId();
$where = array($this->primaryKey => $primaryKey);
}
// refresh data
$result = $this->tableGateway->select($where);
$rowData = $result->current();
$this->populateOriginalData($rowData);
return $rowsAffected;
}
示例6: salvar
/**
*
* @throws Exception
*/
public function salvar()
{
$this->validar();
$this->table->insert(array('nmCargo' => $this->getCargo(), 'dsJustificativa' => $this->getJustificativa()));
}