当前位置: 首页>>代码示例>>PHP>>正文


PHP Insert::columns方法代码示例

本文整理汇总了PHP中Zend\Db\Sql\Insert::columns方法的典型用法代码示例。如果您正苦于以下问题:PHP Insert::columns方法的具体用法?PHP Insert::columns怎么用?PHP Insert::columns使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Db\Sql\Insert的用法示例。


在下文中一共展示了Insert::columns方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: insertSession

 public function insertSession($username, $password, $session_id)
 {
     $insert = new Insert('sessions');
     $adapter = $this->table_gateway->getAdapter();
     $insert->columns(array('username', 'password', 'active', 'session_id'))->values(array('username' => $username, 'password' => $password, 'active' => 1, 'session_id' => $session_id));
     $adapter->query($this->sql->buildSqlString($insert), $adapter::QUERY_MODE_EXECUTE);
     return true;
 }
开发者ID:ponchov,项目名称:teeforall,代码行数:8,代码来源:LoginModel.php

示例2: insertPrivilege

 public function insertPrivilege($attributes)
 {
     $attributes = $this->verifyPrivilege($attributes);
     $status_id = isset($attributes['status_id']) ? $attributes['status_id'] : 0;
     $insert = new Insert($this->getTable());
     $insert->columns(array('table_name', 'permissions', 'group_id'))->values(array('table_name' => $attributes['table_name'], 'permissions' => $attributes['permissions'], 'group_id' => $attributes['group_id'], 'status_id' => $status_id));
     $this->insertWith($insert);
     $privilegeId = $this->lastInsertValue;
     return $this->fetchById($privilegeId);
 }
开发者ID:rudderdon,项目名称:Directus,代码行数:10,代码来源:DirectusPrivilegesTableGateway.php

示例3: preInsert

 /**
  * @param Insert $insert
  */
 public function preInsert(Insert $insert)
 {
     $metaColumns = $this->tableGateway->getColumns();
     if (count($metaColumns)) {
         $metaColumns = array_flip($metaColumns);
         $columns = array_flip($insert->getRawState('columns'));
         $columns = array_flip(array_intersect_key($columns, $metaColumns));
         $values = $insert->getRawState('values');
         $values = array_intersect_key($values, $columns);
         $insert->values(array_values($values));
         $insert->columns(array_values($columns));
     }
 }
开发者ID:zfstarter,项目名称:zfs-domain-model,代码行数:16,代码来源:FilterColumnsFeature.php

示例4: insertPrivilege

 public function insertPrivilege($attributes)
 {
     $attributes = $this->verifyPrivilege($attributes);
     // @todo: this should fallback on field default value
     if (!isset($attributes['status_id'])) {
         $attributes['status_id'] = 0;
     }
     $attributes = $this->getFillableFields($attributes);
     $insert = new Insert($this->getTable());
     $insert->columns(array_keys($attributes))->values($attributes);
     $this->insertWith($insert);
     $privilegeId = $this->lastInsertValue;
     return $this->fetchById($privilegeId);
 }
开发者ID:hyrmedia,项目名称:directus,代码行数:14,代码来源:DirectusPrivilegesTableGateway.php

示例5: testGetSqlString

 /**
  * @covers Zend\Db\Sql\Insert::getSqlString
  */
 public function testGetSqlString()
 {
     $this->insert->into('foo')->values(array('bar' => 'baz', 'boo' => new Expression('NOW()'), 'bam' => null));
     $this->assertEquals('INSERT INTO "foo" ("bar", "boo", "bam") VALUES (\'baz\', NOW(), NULL)', $this->insert->getSqlString(new TrustingSql92Platform()));
     // with TableIdentifier
     $this->insert = new Insert();
     $this->insert->into(new TableIdentifier('foo', 'sch'))->values(array('bar' => 'baz', 'boo' => new Expression('NOW()'), 'bam' => null));
     $this->assertEquals('INSERT INTO "sch"."foo" ("bar", "boo", "bam") VALUES (\'baz\', NOW(), NULL)', $this->insert->getSqlString(new TrustingSql92Platform()));
     // with Select
     $this->insert = new Insert();
     $select = new Select();
     $this->insert->into('foo')->select($select->from('bar'));
     $this->assertEquals('INSERT INTO "foo"  SELECT "bar".* FROM "bar"', $this->insert->getSqlString(new TrustingSql92Platform()));
     // with Select and columns
     $this->insert->columns(array('col1', 'col2'));
     $this->assertEquals('INSERT INTO "foo" ("col1", "col2") SELECT "bar".* FROM "bar"', $this->insert->getSqlString(new TrustingSql92Platform()));
 }
开发者ID:pnaq57,项目名称:zf2demo,代码行数:20,代码来源:InsertTest.php

示例6: preInsert

 public function preInsert(Insert $insert)
 {
     $columns = $insert->getRawState('columns');
     $values = $insert->getRawState('values');
     $key = array_search($this->primaryKeyField, $columns);
     if ($key !== false) {
         $this->sequenceValue = $values[$key];
         return $insert;
     }
     $this->sequenceValue = $this->nextSequenceId();
     if ($this->sequenceValue === null) {
         return $insert;
     }
     array_push($columns, $this->primaryKeyField);
     array_push($values, $this->sequenceValue);
     $insert->columns($columns);
     $insert->values($values);
     return $insert;
 }
开发者ID:Yansor,项目名称:yafblog,代码行数:19,代码来源:SequenceFeature.php

示例7: sendMessage

 public function sendMessage($payload, $recipients, $from)
 {
     $defaultValues = ['response_to' => null];
     $payload = array_merge($defaultValues, $payload);
     $insert = new Insert($this->getTable());
     $insert->columns(['from', 'subject', 'message'])->values(['from' => $from, 'subject' => $payload['subject'], 'message' => $payload['message'], 'datetime' => DateUtils::now(), 'response_to' => $payload['response_to']]);
     $rows = $this->insertWith($insert);
     $messageId = $this->lastInsertValue;
     // Insert recipients
     $values = [];
     foreach ($recipients as $recipient) {
         $read = 0;
         if ((int) $recipient == (int) $from) {
             $read = 1;
         }
         $values[] = '(' . $messageId . ', ' . $recipient . ', ' . $read . ')';
     }
     $valuesString = implode(',', $values);
     //@todo sanitize and implement ACL
     $sql = 'INSERT INTO directus_messages_recipients (`message_id`, `recipient`, `read`) VALUES ' . $valuesString;
     $result = $this->adapter->query($sql, Adapter::QUERY_MODE_EXECUTE);
     return $messageId;
 }
开发者ID:YounessTayer,项目名称:directus,代码行数:23,代码来源:DirectusMessagesTableGateway.php

示例8: sendMessage

 public function sendMessage($payload, $recipients, $from)
 {
     $defaultValues = array('response_to' => null);
     $payload = array_merge($defaultValues, $payload);
     $insert = new Insert($this->getTable());
     $insert->columns(array('from', 'subject', 'message'))->values(array('from' => $from, 'subject' => $payload['subject'], 'message' => $payload['message'], 'datetime' => gmdate("Y-m-d H:i:s"), 'response_to' => $payload['response_to']));
     $rows = $this->insertWith($insert);
     $messageId = $this->lastInsertValue;
     // Insert recipients
     $values = array();
     foreach ($recipients as $recipient) {
         $read = 0;
         if ((int) $recipient == (int) $from) {
             $read = 1;
         }
         $values[] = "({$messageId}, {$recipient}, {$read})";
     }
     $valuesString = implode(',', $values);
     //@todo sanitize and implement ACL
     $sql = "INSERT INTO directus_messages_recipients (`message_id`, `recipient`, `read`) VALUES {$valuesString}";
     $result = $this->adapter->query($sql, Adapter::QUERY_MODE_EXECUTE);
     return $messageId;
 }
开发者ID:hyrmedia,项目名称:directus,代码行数:23,代码来源:DirectusMessagesTableGateway.php

示例9: testColumns

 /**
  * @covers Zend\Db\Sql\Insert::columns
  */
 public function testColumns()
 {
     $this->insert->columns(array('foo', 'bar'));
     $this->assertEquals(array('foo', 'bar'), $this->readAttribute($this->insert, 'columns'));
 }
开发者ID:Rovak,项目名称:zf2,代码行数:8,代码来源:InsertTest.php

示例10: index05Action

 public function index05Action()
 {
     $table = "user";
     $adapter = $this->getServiceLocator()->get("db_books");
     $tableGateway = new TableGateway($table, $adapter);
     $insertObj = new Insert("user");
     $insertObj->columns(array("name", "email"))->values(array("name" => "Armasky", "email" => "ak@hotmail.com"));
     $tableGateway->insertWith($insertObj);
     //last record inserted
     echo $tableGateway->getLastInsertValue();
     return false;
 }
开发者ID:trongle,项目名称:zend-2,代码行数:12,代码来源:TableGatewayController.php


注:本文中的Zend\Db\Sql\Insert::columns方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。