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


PHP ADODB_mysqli::getOne方法代码示例

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


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

示例1: hasTable

 /**
  * {@inheritdoc}
  * @see Scalr\Upgrade.UpdateInterface::hasTable()
  */
 public function hasTable($table, $database = null)
 {
     $ret = $this->db->getOne("SHOW TABLES " . ($database ? "FROM `" . $this->db->escape($database) . "` " : "") . "LIKE ?", array($table));
     return $ret ? true : false;
 }
开发者ID:rickb838,项目名称:scalr,代码行数:9,代码来源:AbstractUpdate.php

示例2: setAccountRole

 /**
  * Saves account role to database
  *
  * @param   int        $accountId     The ID of the account.
  * @param   int        $baseRoleId    The ID of the base role.
  * @param   string     $name          The name of the account role.
  * @param   int        $color         The color specified as integer value
  * @param   array      $resources     Array of the resources which looks like
  *                                    array(
  *                                        resource_id => array(
  *                                            'granted' => [0|1], #is granted
  *                                            'permissions' => array(
  *                                                permissionId => [0|1], #is granted
  *                                            ),
  *                                            mode => valueId | null, # identifier of the Resource Mode value
  *                                    );
  * @param   string     $accountRoleId optional The ID of the ACL role of account level. NULL if the new role.
  * @return  string     Returns the ID of the created or modified account role on success
  * @throws  \Scalr\Acl\Exception\AclException
  */
 public function setAccountRole($accountId, $baseRoleId, $name, $color, $resources, $accountRoleId = null)
 {
     $id = $this->db->getOne('SELECT account_role_id FROM `acl_account_roles` WHERE name = ? AND account_id = ? LIMIT 1', [$name, $accountId]);
     if ($id && $accountRoleId != $id) {
         throw new \Exception('Account role with such name already exists');
     }
     if (empty($accountRoleId)) {
         //Creates new account role
         $accountRoleId = self::generateAccountRoleId();
         $new = true;
     }
     $this->db->Execute("\n            INSERT `acl_account_roles`\n            SET `account_role_id` = ?,\n                `account_id` = ?,\n                `role_id` = ?,\n                `name` = ?,\n                `color` = ?,\n                `is_automatic` = 0\n            ON DUPLICATE KEY UPDATE\n                `role_id` = ?,\n                `name` = ?,\n                `color` = ?\n        ", array($accountRoleId, $accountId, $baseRoleId, $name, $color, $baseRoleId, $name, $color));
     $accountRole = $this->getAccountRole($accountRoleId);
     if ($accountRole === null) {
         throw new Exception\AclException($new ? 'Database error' : 'Cannot find requested ACL role!');
     }
     $baseRole = $accountRole->getBaseRole();
     foreach ($accountRole->getIteratorResources() as $resourceDefinition) {
         /* @var $resourceDefinition \Scalr\Acl\Resource\ResourceObject */
         $resourceId = $resourceDefinition->getResourceId();
         $accountResource = $accountRole->getResource($resourceId);
         $toUpdate = null;
         $toUpdatePerm = [];
         foreach ($resourceDefinition->getPermissions() as $permissionId => $permissionName) {
             $granted = isset($resources[$resourceId]['permissions'][$permissionId]) ? $resources[$resourceId]['permissions'][$permissionId] == 1 : false;
             if ($granted != $baseRole->isAllowed($resourceId, $permissionId)) {
                 //Unique permission is overridden on account level and needs to be created
                 $toUpdatePerm[$permissionId] = [$accountRoleId, $resourceId, $permissionId, $granted ? 1 : 0, $granted ? 1 : 0];
             } else {
                 if ($accountResource !== null) {
                     //Unique permission needs to be removed
                     $this->db->Execute("\n                        DELETE FROM `acl_account_role_resource_permissions`\n                        WHERE `account_role_id` = ?\n                        AND `resource_id` = ?\n                        AND `perm_id` = ?\n                    ", array($accountRoleId, $resourceId, $permissionId));
                 }
             }
         }
         $granted = isset($resources[$resourceId]['granted']) ? $resources[$resourceId]['granted'] == 1 : false;
         if ($granted != $baseRole->isAllowed($resourceId)) {
             //Resource record is overridden on account level and needs to be created
             $toUpdate = array($accountRoleId, $resourceId, $granted ? 1 : 0, $granted ? 1 : 0);
         } elseif ($resourceDefinition->getMode() !== null || !empty($toUpdatePerm) && $granted) {
             //Referenced resource must be created as foreign key requires.
             $toUpdate = array($accountRoleId, $resourceId, $granted ? 1 : null, $granted ? 1 : null);
         } else {
             //Resource record the same as in the base role and needs to be removed
             $this->db->Execute("\n                    DELETE FROM `acl_account_role_resources`\n                    WHERE `account_role_id` = ?\n                    AND `resource_id` = ?\n                ", array($accountRoleId, $resourceId));
         }
         if ($toUpdate) {
             $this->db->Execute("\n                    INSERT `acl_account_role_resources`\n                    SET `account_role_id` = ?,\n                        `resource_id` = ?,\n                        `granted` = ?\n                    ON DUPLICATE KEY UPDATE\n                        `granted` = ?\n                ", $toUpdate);
         }
         if ($resourceDefinition->getMode() !== null) {
             //Saves ACL Resource Mode only if it's defined in the Resouce Definition
             $modeValue = !empty($resources[$resourceId]['mode']) && in_array(intval($resources[$resourceId]['mode']), array_keys($resourceDefinition->getMode()->getMapping())) ? intval($resources[$resourceId]['mode']) : $resourceDefinition->getMode()->getDefault();
             $this->db->Execute("\n                    INSERT `acl_account_role_resource_modes`\n                    SET `account_role_id` = ?,\n                        `resource_id` = ?,\n                        `mode` = ?\n                    ON DUPLICATE KEY UPDATE\n                        `mode` = ?\n                ", [$accountRoleId, $resourceId, $modeValue, $modeValue]);
         }
         if ($toUpdatePerm) {
             foreach ($toUpdatePerm as $opt) {
                 $this->db->Execute("\n                        INSERT `acl_account_role_resource_permissions`\n                        SET `account_role_id` = ?,\n                            `resource_id` = ?,\n                            `perm_id` = ?,\n                            `granted` = ?\n                        ON DUPLICATE KEY UPDATE\n                            `granted` = ?\n                    ", $opt);
             }
         }
     }
     return $accountRoleId;
 }
开发者ID:scalr,项目名称:scalr,代码行数:82,代码来源:Acl.php

示例3: hasPriceForUrl

 /**
  * Checks whether there is some price for specified platform and url
  *
  * @param    string    $platform      Cloud platform
  * @param    string    $url           The endpoint url
  * @param    string    $cloudLocation optional The cloud location
  * @return   bool      Returns TRUE if there is some price for specified platform and url or FALSE otherwise
  */
 public function hasPriceForUrl($platform, $url, $cloudLocation = null)
 {
     $res = $this->cadb->getOne("\n            SELECT EXISTS(\n                SELECT 1 FROM `price_history`\n                WHERE `platform` = ? AND url = ?\n                " . (!empty($cloudLocation) ? "AND cloud_location = " . $this->cadb->qstr($cloudLocation) : "") . "\n            ) AS `val`\n        ", [$platform, empty($url) ? '' : $this->normalizeUrl($url)]);
     return !!$res;
 }
开发者ID:mheydt,项目名称:scalr,代码行数:13,代码来源:Prices.php

示例4: hasTable

 /**
  * {@inheritdoc}
  * @see Scalr\Upgrade.UpdateInterface::hasTable()
  */
 public function hasTable($table)
 {
     $ret = $this->db->getOne("SHOW TABLES LIKE ?", array($table));
     return $ret ? true : false;
 }
开发者ID:recipe,项目名称:scalr,代码行数:9,代码来源:AbstractUpdate.php


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