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


PHP DibiConnection::getInsertId方法代码示例

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


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

示例1: save

 /**
  * @param array|\DibiRow $article
  * @return bool
  */
 public function save(&$article)
 {
     if (!isset($article['id'])) {
         $this->database->insert(self::TABLE, $article)->execute();
         $article['id'] = $this->database->getInsertId();
     } else {
         $this->database->update(self::TABLE, $article)->where(self::TABLE, '.id = %i', $article['id'])->execute();
     }
     return $this->database->getAffectedRows() == 1;
 }
开发者ID:josiff,项目名称:fri-sandbox,代码行数:14,代码来源:ArticleModel.php

示例2: testFindByPrimary

 public function testFindByPrimary()
 {
     // find by primary
     // insert new article
     $this->db->insert("pages", array("name" => "Find test", "description" => "Find by primary", "text" => "Nějaký text.", "allowed" => true))->execute();
     $id = $this->db->getInsertId();
     $o = $this->object->find($id);
     $this->assertType("Page", $o);
     $this->assertEquals("Find test", $o->name);
 }
开发者ID:janmarek,项目名称:Ormion,代码行数:10,代码来源:MapperTest.php

示例3: insert

 public function insert($values)
 {
     if (empty($this->table)) {
         throw new \Natsu\Model\Exception('Cannot insert - missing table name in model class');
     }
     //return $this->database->lastInsertId($this->table);
     //die('insert');
     $this->database->query("INSERT INTO [{$this->table}]", $values);
     return $this->database->getInsertId();
     //$context = new Context($this->database);
     //$context->table($this->table)->insert($values);
     //return $context->getInsertId();
 }
开发者ID:bombush,项目名称:NatsuCon,代码行数:13,代码来源:EntityModel.php

示例4: updateStructure

 /**
  * funkce pro aktualizaci struktury
  * @param type $relativePath 
  */
 public function updateStructure($relativePath, $ownerId = 0)
 {
     if (empty($relativePath)) {
         return true;
     }
     $relativePath = \Nette\Utils\Strings::endsWith($relativePath, "/") ? substr($relativePath, 0, -1) : $relativePath;
     $parts = explode("/", $relativePath);
     $create = false;
     $count = count($parts);
     $c = 0;
     $parent = 0;
     if ($parts && $count > 0) {
         foreach ($parts as $part) {
             $folder = $this->connection->fetch("SELECT * FROM [:vd:folders] WHERE [name] = %s", $part);
             if (!$folder || $create) {
                 $data = array('parent' => $parent, 'has_child' => $c < $count ? 1 : 0, 'name' => $part, 'nicename' => \Nette\Utils\Strings::webalize($part), 'editor_id' => $ownerId ?: 0);
                 if (!empty($part)) {
                     $this->connection->query('INSERT INTO [:vd:folders] ', $data);
                     $parent = $this->connection->getInsertId();
                 }
             } elseif ($folder) {
                 $parent = $folder['folder_id'];
             }
             if (!$folder || !$folder['has_child']) {
                 $create = true;
             }
             $c++;
         }
     }
     return $parent;
 }
开发者ID:jurasm2,项目名称:bubo,代码行数:35,代码来源:DriveModel.php

示例5: insertItem

 /**
  * @param object $instance
  * @param ClassMetadata $entityAttributes
  * @throws \RuntimeException
  * @return \DibiResult|int
  */
 private function insertItem($instance, ClassMetadata $entityAttributes)
 {
     if ($entityAttributes->hasBeforeCreateEvent()) {
         $instance->beforeCreateEvent($this);
     }
     $values = $this->getInstanceValueMap($instance, $entityAttributes);
     $this->dibiConnection->insert($entityAttributes->getTable(), $values)->execute();
     $insertId = NULL;
     if ($entityAttributes->getAutoIncrementFieldName()) {
         $insertId = $this->dibiConnection->getInsertId();
         if (!$insertId) {
             throw new \RuntimeException('Entity has set autoIncrement flag but no incremented values was returned from DB.');
         }
         DataHelperLoader::setPropertyValue($instance, $entityAttributes->getAutoIncrementFieldName(), $insertId);
     }
     // Unset origin class hash and set new one by primary key
     $hash = spl_object_hash($instance);
     if (array_key_exists($hash, $this->managedClasses)) {
         unset($this->managedClasses[$hash]);
     }
     $classKey = $this->getEntityClassHashKey($instance, $entityAttributes);
     $this->managedClasses[$classKey]['instance'] = $instance;
     $this->managedClasses[$classKey]['flag'] = self::FLAG_INSTANCE_UPDATE;
     $this->managedClasses[$classKey]['valueHash'] = $this->getInstanceValuesHash($instance, $entityAttributes);
     return $insertId;
 }
开发者ID:doublemcz,项目名称:dibi-orm,代码行数:32,代码来源:Manager.php

示例6: addContact

 public function addContact($contact)
 {
     try {
         $this->database->query('INSERT INTO [' . self::TABLE_NAME_CONTACT . ']', [self::COLUMN_ID => $contact['id'], self::COLUMN_EMAIL => $contact['email']]);
         return $this->database->getInsertId();
     } catch (Nette\Database\DriverException $e) {
         throw new \Nette\Database\DriverException();
     }
 }
开发者ID:bombush,项目名称:NatsuCon,代码行数:9,代码来源:UserManager.php

示例7: createInsert

 public function createInsert($table, array $values, $primaryName = null)
 {
     $query = new Query($this->connection->insert($table, $values));
     $query->resultCallback = function (Query $query) {
         $query->fluent->execute();
         return $this->connection->getInsertId();
     };
     return $query;
 }
开发者ID:bauer01,项目名称:unimapper-dibi,代码行数:9,代码来源:Adapter.php

示例8: insertEntity

 /**
  * @param \obo\Entity $entity
  * @return void
  */
 public function insertEntity(\obo\Entity $entity)
 {
     if ($entity->isBasedInRepository()) {
         throw new \obo\Exceptions\Exception("Can't insert entity into storage. Entity is already persisted.");
     }
     $this->dibiConnection->query("INSERT INTO [{$entity->entityInformation()->repositoryName}] ", $this->convertDataForImport($entity->changedProperties($entity->entityInformation()->persistablePropertiesNames, true, true), $entity->entityInformation()));
     if ($autoIncrementProperty = $this->informations[$entity->entityInformation()->className]["autoIncrementProperty"]) {
         $entity->setValueForPropertyWithName($this->dibiConnection->getInsertId(), $autoIncrementProperty);
     }
 }
开发者ID:lordjim666,项目名称:data-storage-mysql,代码行数:14,代码来源:MySQL.php

示例9: execute

 /**
  * Generates and executes SQL query.
  * @param  mixed what to return?
  * @return DibiResult|int  result set object (if any)
  * @throws DibiException
  */
 public function execute($return = NULL)
 {
     $res = $this->query($this->_export());
     switch ($return) {
         case dibi::IDENTIFIER:
             return $this->connection->getInsertId();
         case dibi::AFFECTED_ROWS:
             return $this->connection->getAffectedRows();
         default:
             return $res;
     }
 }
开发者ID:ludik1,项目名称:transport_company,代码行数:18,代码来源:DibiFluent.php

示例10: execute

 /**
  * Generates and executes SQL query.
  * @param  mixed what to return?
  * @return DibiResult|int  result set object (if any)
  * @throws DibiException
  */
 public function execute($return = NULL)
 {
     $res = $this->connection->query($this->_export());
     return $return === dibi::IDENTIFIER ? $this->connection->getInsertId() : $res;
 }
开发者ID:nella,项目名称:ActiveMapper,代码行数:11,代码来源:DibiFluent.php

示例11: foreach

     echo "<option value='' selected></option>";
     foreach ($rows as $row) {
         echo "<option value='" . $row['code'] . "'>" . $row['name'] . "</option>";
     }
     break;
 case "savetext":
     $language = mysql_real_escape_string(isset($_POST['language']) ? $_POST['language'] : '');
     // It will be possible to use Null Coalesce Operator in PHP 7, see: https://wiki.php.net/rfc/isset_ternary
     $title = mysql_real_escape_string(isset($_POST['title']) ? $_POST['title'] : '');
     $text = mysql_real_escape_string(isset($_POST['text']) ? $_POST['text'] : '');
     $level = mysql_real_escape_string(isset($_POST['level']) ? $_POST['level'] : '');
     $source = mysql_real_escape_string(isset($_POST['source']) ? $_POST['source'] : '');
     $url = mysql_real_escape_string(isset($_POST['url']) ? $_POST['url'] : '');
     $public = mysql_real_escape_string(isset($_POST['pub']) ? $_POST['pub'] : '');
     $db->query("INSERT INTO Texts (language,title,text,level,source,url,public) VALUES ('" . $language . "','" . $title . "','" . $text . "','" . $level . "','" . $source . "','" . $url . "','" . $public . "')");
     echo $db->getInsertId();
     break;
 case "savetest":
     $secret = uniqid();
     $language = mysql_real_escape_string(isset($_POST['language']) ? $_POST['language'] : '');
     $text = mysql_real_escape_string(isset($_POST['text']) ? $_POST['text'] : '');
     $testtype = mysql_real_escape_string(isset($_POST['testtype']) ? $_POST['testtype'] : '');
     $test = mysql_real_escape_string(isset($_POST['test']) ? $_POST['test'] : '');
     $solution = isset($_POST['solution']) ? $_POST['solution'] : '';
     $db->query("INSERT INTO Tests (secret,language,text,testtype,test,solution) VALUES ('" . $secret . "','" . $language . "','" . $text . "','" . $testtype . "','" . $test . "','" . $solution . "')");
     echo $secret;
     break;
 case "sendtest":
     $secret = mysql_real_escape_string(isset($_POST['secretId']) ? $_POST['secretId'] : '');
     $level = mysql_real_escape_string(isset($_POST['level']) ? $_POST['level'] : '');
     $public = mysql_real_escape_string(isset($_POST['pub']) ? $_POST['pub'] : '');
开发者ID:WesleyYep,项目名称:text2test,代码行数:31,代码来源:query.php

示例12: getLastId

 public function getLastId()
 {
     return $this->connection->getInsertId();
 }
开发者ID:jurasm2,项目名称:bubo,代码行数:4,代码来源:BaseModel.php

示例13: insert

 public function insert(array $data)
 {
     $this->dibi->query('INSERT INTO %n', $this->table_name, $data);
     return $this->dibi->getInsertId();
 }
开发者ID:kramapet,项目名称:nested-set,代码行数:5,代码来源:DibiQueryMapper.php

示例14: createIdentity

 /**
  * Creates IIdentity object from obtained user data
  *
  * @param mixed user data
  * @param IAuthenticator authenticator
  *
  * @return IIdentity
  */
 public function createIdentity($userData, $authenticator)
 {
     $uid = NULL;
     $roles = array();
     $profile = array();
     // ---------------------------------------------------------------------
     // DB Password
     if ($authenticator instanceof Authenticators\DatabasePasswordAuthenticator) {
         $uid = (int) $userData->{$authenticator->getColumn($authenticator::ID)};
         $profile = $userData;
     } elseif ($authenticator instanceof Authenticators\LdapBindAuthenticator) {
         $ldapData = (array) $userData;
         $idCol = 'id';
         $tableName = 'security_users';
         // LDAP Binding
         // DB column name -> ldap array key (or callable)
         $binding = array(array('username' => function ($ldapData) use($authenticator) {
             return mb_substr($ldapData['dn'], mb_strlen($authenticator->getQueryPrefix()), 0 - mb_strlen($authenticator->getQuerySuffix()));
         }), array('name' => 'givenName', 'surname' => 'sn', 'email' => function ($ldapData) use(&$binding) {
             $username = $binding[0]['username']($ldapData);
             $tokens = Strings::splitWithEscape($ldapData['dn'], ',dc=');
             array_shift($tokens);
             return $username . '@' . implode($tokens, '.');
         }));
         // Prepare data based on LDAP binding
         $boundData = $this->bindValues($ldapData, $binding[0]);
         $this->db->query('LOCK TABLES %n WRITE', $tableName);
         $ds = $this->db->select('*')->from($tableName);
         foreach ($boundData as $key => $value) {
             $ds->where('%n = %s', $key, $value);
         }
         $profile = $ds->fetch();
         // If profile does not exist yet
         if ($profile === FALSE) {
             $boundData = array_merge($boundData, $this->bindValues($ldapData, $binding[1]));
             $this->db->insert($tableName, $boundData)->execute();
             $boundData[$idCol] = $uid = (int) $this->db->getInsertId();
             $profile = $boundData;
         } else {
             $uid = (int) $profile[$idCol];
         }
         $this->db->query('UNLOCK TABLES');
         // TODO: configurable
         $groupsDn = NULL;
         if ($groupsDn == NULL) {
             $dnTokens = array_reverse($userData->getParsedDn());
             foreach ($dnTokens as $k => $v) {
                 if (!Strings::startsWith($v, 'dc=')) {
                     array_splice($dnTokens, $k, count($dnTokens), array('ou=groups'));
                     break;
                 }
             }
             $groupDn = implode(array_reverse($dnTokens), ',');
         }
         $username = str_replace(array('\\', ')'), array('\\\\', '\\)'), $boundData['username']);
         $userGid = intval($userData->gidNumber);
         $filter = "(&(objectClass=posixGroup)(|(gidNumber={$userGid})(memberUid={$username})))";
         $result = $authenticator->ldapConnection->search($groupsDn, $filter);
         foreach ($result as $record) {
             $roles[] = $record->cn;
         }
     } elseif ($authenticator instanceof Authenticators\DatabasePSKAuthenticator) {
         $uid = Strings::intoParameterizedString('psk', array($userData->key));
         $roles[] = $uid;
         $profile = $userData;
         // Other authenticators
     } else {
         throw new Nette\NotSupportedException("Authenticator " . get_class($authenticator) . " not supported yet");
     }
     // ---------------------------------------------------------------------
     // Remove duplicit roles
     $roles = array_unique($roles);
     // Sanity check
     if (!is_scalar($uid) || $uid == "") {
         throw new Nette\InvalidStateException("User ID has to be non-empty string or number");
     }
     // ---------------------------------------------------------------------
     // Query roles from DB if it's not PSK (has user id)
     if (is_int($uid)) {
         $roles = array_merge($this->getUserRoles($uid), $roles);
     }
     // ---------------------------------------------------------------------
     // Identity
     $identity = new Nette\Security\Identity($uid, $roles, $profile);
     return $identity;
 }
开发者ID:vbuilder,项目名称:framework,代码行数:94,代码来源:IdentityFactory.php


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