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


PHP Insert::prepareStatement方法代码示例

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


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

示例1: testPrepareStatement

 /**
  * @covers Zend\Db\Sql\Insert::prepareStatement
  */
 public function testPrepareStatement()
 {
     $mockDriver = $this->getMock('Zend\\Db\\Adapter\\Driver\\DriverInterface');
     $mockDriver->expects($this->any())->method('getPrepareType')->will($this->returnValue('positional'));
     $mockDriver->expects($this->any())->method('formatParameterName')->will($this->returnValue('?'));
     $mockAdapter = $this->getMock('Zend\\Db\\Adapter\\Adapter', null, array($mockDriver));
     $mockStatement = $this->getMock('Zend\\Db\\Adapter\\Driver\\StatementInterface');
     $pContainer = new \Zend\Db\Adapter\ParameterContainer(array());
     $mockStatement->expects($this->any())->method('getParameterContainer')->will($this->returnValue($pContainer));
     $mockStatement->expects($this->at(1))->method('setSql')->with($this->equalTo('INSERT INTO "foo" ("bar", "boo") VALUES (?, NOW())'));
     $this->insert->into('foo')->values(array('bar' => 'baz', 'boo' => new Expression('NOW()')));
     $this->insert->prepareStatement($mockAdapter, $mockStatement);
     // with TableIdentifier
     $this->insert = new Insert();
     $mockDriver = $this->getMock('Zend\\Db\\Adapter\\Driver\\DriverInterface');
     $mockDriver->expects($this->any())->method('getPrepareType')->will($this->returnValue('positional'));
     $mockDriver->expects($this->any())->method('formatParameterName')->will($this->returnValue('?'));
     $mockAdapter = $this->getMock('Zend\\Db\\Adapter\\Adapter', null, array($mockDriver));
     $mockStatement = $this->getMock('Zend\\Db\\Adapter\\Driver\\StatementInterface');
     $pContainer = new \Zend\Db\Adapter\ParameterContainer(array());
     $mockStatement->expects($this->any())->method('getParameterContainer')->will($this->returnValue($pContainer));
     $mockStatement->expects($this->at(1))->method('setSql')->with($this->equalTo('INSERT INTO "sch"."foo" ("bar", "boo") VALUES (?, NOW())'));
     $this->insert->into(new TableIdentifier('foo', 'sch'))->values(array('bar' => 'baz', 'boo' => new Expression('NOW()')));
     $this->insert->prepareStatement($mockAdapter, $mockStatement);
 }
开发者ID:razvansividra,项目名称:pnlzf2-1,代码行数:28,代码来源:InsertTest.php

示例2: prepareStatement

 public function prepareStatement(AdapterInterface $adapter, StatementContainerInterface $statementContainer)
 {
     /* init */
     $this->hasAutoincrement = false;
     /* parent prep */
     $result = parent::prepareStatement($adapter, $statementContainer);
     /* oci8 with autoincrement */
     if ($statementContainer instanceof \Zend\Db\Adapter\Driver\Oci8\Statement && $this->autoincrement !== null) {
         /* get sequence */
         if ($this->sequence === null) {
             $this->sequence = 'SEQ_' . $this->table;
         }
         /* replace ai field with sequence & move ai field binding to the end with returning */
         $count = 0;
         $sql = preg_replace('/:' . $this->autoincrement . '\\s*/', $this->sequence . '.NEXTVAL', $statementContainer->getSql(), 1, $count) . ' RETURNING "' . $this->autoincrement . '" INTO :' . $this->autoincrement;
         /* anything replaced? */
         if ($count > 0) {
             /* prep statement to prep resource */
             $statementContainer->setSql($sql);
             $statementContainer->prepare();
             /* unset ai field */
             $statementContainer->getParameterContainer()->offsetUnset($this->autoincrement);
             /* get ai field position on values */
             $position = array_search($this->autoincrement, $this->columns);
             $this->values[$position] = 0;
             $this->hasAutoincrement = true;
             oci_bind_by_name($statementContainer->getResource(), $this->autoincrement, $this->values[$position], -1, SQLT_INT);
         }
     }
     //oci8 AI
     return $result;
 }
开发者ID:jafarsidik,项目名称:neuron,代码行数:32,代码来源:Insert.php

示例3: prepareStatement

 /**
  * Prepare statement
  *
  * @param  AdapterInterface $adapter
  * @param  StatementContainerInterface $statementContainer
  * @return void
  */
 public function prepareStatement(AdapterInterface $adapter, StatementContainerInterface $statementContainer)
 {
     parent::prepareStatement($adapter, $statementContainer);
     $sql = $statementContainer->getSql();
     $statementContainer->setSql($sql . "ON DUPLICATE KEY UPDATE " . implode(",", array_map(array($this, "mapValue"), $this->columns)));
 }
开发者ID:remithomas,项目名称:rt-extends,代码行数:13,代码来源:DuplicateInsert.php


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