本文整理汇总了PHP中Zend\Db\Sql\Sql::insert方法的典型用法代码示例。如果您正苦于以下问题:PHP Sql::insert方法的具体用法?PHP Sql::insert怎么用?PHP Sql::insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Db\Sql\Sql
的用法示例。
在下文中一共展示了Sql::insert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveItem
public function saveItem($arrParam = null, $options = null)
{
if ($options['task'] == 'add') {
$sqlObj = new \Zend\Db\Sql\Sql($this->adapter);
$insertObj = $sqlObj->insert('service_account_register');
$insertObj->values($arrParam);
$sqlString = $sqlObj->getSqlStringForSqlObject($insertObj);
$this->adapter->query($sqlString)->execute();
}
if ($options['task'] == 'edit') {
$this->tableGateway->update($arrParam, array('id' => $arrParam['id']));
}
if ($options['task'] == 'multi-status') {
if (!empty($arrParam)) {
foreach ($arrParam['id'] as $key => $value) {
if ($arrParam['type'] == 'multi-active') {
$status = 1;
}
if ($arrParam['type'] == 'multi-in-active') {
$status = 0;
}
$data = array('id' => $value, 'status' => $status);
$this->tableGateway->update($data, array('id' => $value));
}
}
}
}
示例2: insert
public function insert($data)
{
$insert = $this->sql->insert($this->_table);
$insert->values($data);
$result = $this->_execute($insert);
return $result->getGeneratedValue();
}
示例3: addNew
/**
* Adds a new record of the Room object in the database.
* @param Room $room - a populated object to add.
*/
public function addNew(Room $room)
{
$adapter = $this->getServiceLocator()->get('Zend\\Db\\Adapter\\Adapter');
$sql = new Sql($adapter);
$insert = $sql->insert('room')->columns(array('number', 'name', 'building', 'attendant', 'posts'))->values(array('number' => $room->number, 'name' => $room->name, 'building' => $room->building, 'attendant' => $room->attendant, 'posts' => $room->posts));
$sql->prepareStatementForSqlObject($insert)->execute();
}
示例4: saveUser
/**
* Saves a user to a database
*
* @param array $user
*/
public function saveUser(array $user)
{
$sql = new Sql($this->dbAdapter);
$insert = $sql->insert('users');
$insert->columns(array_keys($user))->values($user);
$sql->prepareStatementForSqlObject($insert)->execute();
}
示例5: create
/**
* @return bool $successfulCreate
*/
protected function create() : bool
{
$insert = $this->sql->insert($this->getTablename());
$id = $this->adapter->getDriver()->getConnection()->getLastGeneratedValue();
$this->load($id);
$success = true;
return $success;
}
示例6: addRole
public function addRole($serviceManager, $userRoleTable, $userIdField, $roleIdField, $userId, $roleId)
{
$adapter = $serviceManager->get('Zend\\Db\\Adapter\\Adapter');
$sql = new Sql($adapter);
$insert = $sql->insert()->into($userRoleTable)->columns(array($userIdField, $roleIdField))->values(array($userId, $roleId));
$sqlString = $sql->getSqlStringForSqlObject($insert);
$execute = $adapter->query($sqlString, $adapter::QUERY_MODE_EXECUTE);
return $execute;
}
示例7: insert
public function insert($data)
{
$adapter = $this->adapter;
$sql = new Sql($this->adapter);
$insert = $sql->insert('item_price');
$insert->values($data);
$selectString = $sql->getSqlStringForSqlObject($insert);
return $results = $this->adapter->query($selectString, $adapter::QUERY_MODE_EXECUTE);
}
示例8: insert
/**
*
* @param string $tableName
* @param array $data
* @return bool
*/
public function insert($tableName, array $data)
{
$sql = new Sql($this->adapter);
$insert = $sql->insert($tableName);
$insert->values($data);
$sqlString = $sql->getSqlStringForSqlObject($insert);
$results = $this->adapter->query($sqlString, Adapter::QUERY_MODE_EXECUTE);
return $results;
}
示例9: insert
/**
* Insert
*
* @param array $set
* @return int
*/
public function insert($set)
{
if (!$this->isInitialized) {
$this->initialize();
}
$insert = $this->sql->insert();
$insert->values($set);
return $this->executeInsert($insert);
}
示例10: insert
/**
* Insert
*
* @param array $set
* @return int
*/
public function insert($set)
{
$insert = $this->sql->insert();
$insert->values($set);
$statement = $this->sql->prepareStatementForSqlObject($insert);
$result = $statement->execute();
$this->lastInsertValue = $this->adapter->getDriver()->getConnection()->getLastGeneratedValue();
return $result->getAffectedRows();
}
示例11: createTransaction
public function createTransaction($data)
{
$adapter = $this->adapter;
$sql = new Sql($this->adapter);
$insert = $sql->insert('user_transaction');
$insert->values($data);
$selectString = $sql->getSqlStringForSqlObject($insert);
$results = $this->adapter->query($selectString, $adapter::QUERY_MODE_EXECUTE);
return array("trnx_id" => $results->getGeneratedValue());
}
示例12: create
public function create(array $data)
{
$sql = new Sql($this->adapter);
$this->adapter->getDriver()->getConnection()->beginTransaction();
$insert = $sql->insert('places');
$insert->values(['name' => $data['name'], 'latitude' => $data['latitude'], 'longitude' => $data['longitude']]);
$query = $sql->getSqlStringForSqlObject($insert);
/** @var Result $results */
$results = $this->adapter->query($query, Adapter::QUERY_MODE_EXECUTE);
$placeId = $results->getGeneratedValue();
foreach ($data['types'] as $typeId) {
$insert = $sql->insert('places_place_types');
$insert->values(['place_id' => $placeId, 'place_type_id' => $typeId]);
$q = $sql->getSqlStringForSqlObject($insert);
$this->adapter->query($q, Adapter::QUERY_MODE_EXECUTE);
}
$this->adapter->getDriver()->getConnection()->commit();
return $placeId;
}
示例13: addNew
/**
* Adds a new record of the Equipment object in the database.
* @param Equipment $equipment - a populated object to add.
*/
public function addNew(Equipment $equipment)
{
if (!$this->is_init()) {
throw new \Exception("Equipments collection uninitiated.");
}
$adapter = $this->getServiceLocator()->get('Zend\\Db\\Adapter\\Adapter');
$sql = new Sql($adapter);
$insert = $sql->insert('equipment')->columns(array('cid', 'name', 'quantity', 'destiny', 'damaged', 'hire', 'adddate'))->values(array('cid' => $equipment->cid, 'name' => $equipment->name, 'quantity' => $equipment->quantity, 'destiny' => $equipment->destiny, 'damaged' => $equipment->damaged, 'hire' => $equipment->hire, 'adddate' => $equipment->adddate));
$sql->prepareStatementForSqlObject($insert)->execute();
}
示例14: create
public function create($id)
{
$sql = new Sql($this->getAdapter());
$insert = $sql->insert($this->getTableName());
$insert->values(['id' => (string) $id]);
$query = $sql->getSqlStringForSqlObject($insert);
/** @var Result $results */
$results = $this->adapter->query($query, Adapter::QUERY_MODE_EXECUTE);
return $results->getGeneratedValue();
}
示例15: saveHuntClubsHasPlayers
public function saveHuntClubsHasPlayers($data)
{
$adapter = $this->tableGateway->getAdapter();
$sql = new Sql($adapter);
$insert = $sql->insert('hunt_clubs_has_players');
$insert->values($data);
$statement = $sql->prepareStatementForSqlObject($insert);
$results = $statement->execute();
$id = $adapter->getDriver()->getLastGeneratedValue();
return $id;
}