本文整理汇总了PHP中ADODB_mysqli类的典型用法代码示例。如果您正苦于以下问题:PHP ADODB_mysqli类的具体用法?PHP ADODB_mysqli怎么用?PHP ADODB_mysqli使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ADODB_mysqli类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: takeCredits
public static function takeCredits(\PDO $pdo_db, \ADODB_mysqli $db, array $langvars, int $planet_id)
{
// Get basic Database information (ship and planet)
$res = $db->Execute("SELECT * FROM {$db->prefix}ships WHERE email = ?;", array($_SESSION['username']));
\Tki\Db::LogDbErrors($pdo_db, $res, __LINE__, __FILE__);
$playerinfo = $res->fields;
$res = $db->Execute("SELECT * FROM {$db->prefix}planets WHERE planet_id = ?;", array($planet_id));
\Tki\Db::LogDbErrors($pdo_db, $res, __LINE__, __FILE__);
$planetinfo = $res->fields;
// Set the name for unamed planets to be "unnamed"
if (empty($planetinfo['name'])) {
$planetinfo['name'] = $langvars['l_unnamed'];
}
// Verify player is still in same sector as the planet
if ($playerinfo['sector'] == $planetinfo['sector_id']) {
if ($playerinfo['turns'] >= 1) {
// Verify player owns the planet to take credits from
if ($planetinfo['owner'] == $playerinfo['ship_id']) {
// Get number of credits from the planet and current number player has on ship
$CreditsTaken = $planetinfo['credits'];
$CreditsOnShip = $playerinfo['credits'];
$NewShipCredits = $CreditsTaken + $CreditsOnShip;
// Update the planet record for credits
$res = $db->Execute("UPDATE {$db->prefix}planets SET credits = 0 WHERE planet_id = ?;", array($planetinfo['planet_id']));
\Tki\Db::LogDbErrors($pdo_db, $res, __LINE__, __FILE__);
// update the player info with updated credits
$res = $db->Execute("UPDATE {$db->prefix}ships SET credits = ? WHERE email = ?;", array($NewShipCredits, $_SESSION['username']));
\Tki\Db::LogDbErrors($pdo_db, $res, __LINE__, __FILE__);
// update the player info with updated turns
$res = $db->Execute("UPDATE {$db->prefix}ships SET turns = turns - 1 WHERE email = ?;", array($_SESSION['username']));
\Tki\Db::LogDbErrors($pdo_db, $res, __LINE__, __FILE__);
$tempa1 = str_replace("[credits_taken]", number_format($CreditsTaken, 0, $langvars['local_number_dec_point'], $langvars['local_number_thousands_sep']), $langvars['l_pr_took_credits']);
$tempa2 = str_replace("[planet_name]", $planetinfo['name'], $tempa1);
echo $tempa2 . "<br>";
$tempb1 = str_replace("[ship_name]", $playerinfo['ship_name'], $langvars['l_pr_have_credits_onboard']);
$tempb2 = str_replace("[new_ship_credits]", number_format($NewShipCredits, 0, $langvars['local_number_dec_point'], $langvars['local_number_thousands_sep']), $tempb1);
echo $tempb2 . "<br>";
$retval = "GO";
} else {
echo "<br><br>" . str_replace("[planet_name]", $planetinfo['name'], $langvars['l_pr_not_your_planet']) . "<br><br>";
$retval = "BREAK-INVALID";
}
} else {
$tempc1 = str_replace("[planet_name]", $planetinfo['name'], $langvars['l_pr_not_enough_turns']);
$tempc2 = str_replace("[sector_id]", $planetinfo['sector_id'], $tempc1);
echo "<br><br>" . $tempc2 . "<br><br>";
$retval = "BREAK-TURNS";
}
} else {
echo "<br><br>" . $langvars['l_pr_must_same_sector'] . "<br><br>";
$retval = "BREAK-SECTORS";
}
return $retval;
}
示例2: isConnectionAlive
/**
* Checks whether current connection is alive
*
* @param ADODB_mysqli $conn
* @return bool Returns true on success or false otherwise
*/
private static function isConnectionAlive($conn)
{
$alive = true;
if (!empty($conn->_connectionID) && method_exists($conn->_connectionID, 'ping')) {
$alive = (bool) @$conn->_connectionID->ping();
} else {
try {
$conn->GetOne('SELECT 1');
} catch (\ADODB_Exception $e) {
if (stristr($e->getMessage(), 'has gone away') !== false) {
$alive = false;
}
}
}
return $alive;
}
示例3: enqueueWork
function enqueueWork($workQueue)
{
$this->logger->info("Fetching farms...");
$farms = array();
$envs = $this->db->GetAll('SELECT env_id, value FROM governance WHERE enabled = 1 AND name = ?', array(Scalr_Governance::GENERAL_LEASE));
foreach ($envs as $env) {
$env['value'] = json_decode($env['value'], true);
$period = 0;
if (is_array($env['value']['notifications'])) {
foreach ($env['value']['notifications'] as $notif) {
if ($notif['period'] > $period) {
$period = $notif['period'];
}
}
$dt = new DateTime();
$dt->sub(new DateInterval('P' . $period . 'D'));
$fs = $this->db->GetAll('SELECT farmid, status FROM farm_settings
LEFT JOIN farms ON farms.id = farm_settings.farmid
WHERE farm_settings.name = ? AND status = ? AND env_id = ? AND value > ?', array(DBFarm::SETTING_LEASE_TERMINATE_DATE, FARM_STATUS::RUNNING, $env['env_id'], $dt->format('Y-m-d H:i:s')));
foreach ($fs as $f) {
if (!isset($farms[$f['farmid']])) {
$farms[$f['farmid']] = true;
$workQueue->put($f['farmid']);
}
}
}
}
$this->logger->info("Found " . count($farms) . " lease tasks");
}
示例4: handleWork
function handleWork($msgId)
{
$message = $this->db->GetRow("SELECT server_id, message, id, handle_attempts FROM messages WHERE id=?", array($msgId));
try {
if ($message['handle_attempts'] >= 3) {
$this->db->Execute("UPDATE messages SET status=? WHERE id=?", array(MESSAGE_STATUS::FAILED, $message['id']));
} else {
try {
$DBServer = DBServer::LoadByID($message['server_id']);
} catch (Exception $e) {
$this->db->Execute("UPDATE messages SET status=? WHERE id=?", array(MESSAGE_STATUS::FAILED, $message['id']));
return;
}
if ($DBServer->status == SERVER_STATUS::RUNNING || $DBServer->status == SERVER_STATUS::INIT || $DBServer->status == SERVER_STATUS::IMPORTING || $DBServer->status == SERVER_STATUS::TEMPORARY || $DBServer->status == SERVER_STATUS::PENDING_TERMINATE) {
$msg = $this->messageSerializer->unserialize($message['message']);
$msg->dbMessageId = $message['id'];
$DBServer->SendMessage($msg);
} elseif (in_array($DBServer->status, array(SERVER_STATUS::TROUBLESHOOTING, SERVER_STATUS::TERMINATED, SERVER_STATUS::SUSPENDED))) {
$this->db->Execute("UPDATE messages SET status=? WHERE id=?", array(MESSAGE_STATUS::FAILED, $message['id']));
}
}
} catch (Exception $e) {
//var_dump($e->getMessage());
}
}
示例5: getDb
/**
* Gets MongoDb Collection
*
* @return ADOConnection Returns the instance of the ADOConnection
*/
protected function getDb()
{
if ($this->db === null) {
$this->db = NewADOConnection($this->options['dsn']);
$this->db->SetFetchMode(ADODB_FETCH_ASSOC);
}
return $this->db;
}
示例6: enqueueWork
function enqueueWork($workQueue)
{
$rows = $this->db->GetAll("SELECT id FROM farm_roles WHERE role_id IN (SELECT role_id FROM role_behaviors WHERE behavior IN (?,?,?,?))", array(ROLE_BEHAVIORS::POSTGRESQL, ROLE_BEHAVIORS::REDIS, ROLE_BEHAVIORS::MYSQL2, ROLE_BEHAVIORS::PERCONA));
$this->logger->info("Found " . count($rows) . " DbMsr farm roles...");
foreach ($rows as $row) {
$workQueue->put($row["id"]);
}
}
示例7: enqueueWork
function enqueueWork($workQueue)
{
$this->logger->info("Fetching active farms...");
$rows = $this->db->GetAll("SELECT id FROM dm_deployment_tasks WHERE status IN ('pending','deploying')");
$this->logger->info("Found " . count($rows) . " deployment tasks");
foreach ($rows as $row) {
$workQueue->put($row["id"]);
}
}
示例8: getFinancialAdmins
/**
* Gets all active financial admins
*
* @return array Returns all financial admins array(Scalr_Account_User)
*/
public function getFinancialAdmins()
{
$rs = $this->db->Execute("SELECT id FROM account_users WHERE type = ? AND status = ?", [\Scalr_Account_User::TYPE_FIN_ADMIN, \Scalr_Account_User::STATUS_ACTIVE]);
$result = [];
while ($row = $rs->FetchRow()) {
$user = \Scalr_Account_User::init()->loadById($row['id']);
$result[$user->id] = $user;
}
return $result;
}
示例9: cancelLastRequest
public function cancelLastRequest()
{
$last = $this->getLastRequest();
if ($last && $last['status'] == self::STATUS_PENDING) {
$this->db->Execute('UPDATE farm_lease_requests SET status = ? WHERE id = ?', array(self::STATUS_CANCEL, $last['id']));
return true;
} else {
return false;
}
}
示例10: handle
function handle($queue, Scalr_Messaging_Msg $message, $rawMessage, $type = 'xml')
{
$this->logger->info(sprintf("Received message '%s' from server '%s'", $message->getName(), $message->getServerId()));
try {
$this->db->Execute("INSERT INTO messages SET\n messageid = ?,\n message = ?,\n server_id = ?,\n dtadded = NOW(),\n type = ?,\n ipaddress = ?,\n message_name = ?,\n message_format = ?\n ", array($message->messageId, $rawMessage, $message->getServerId(), "in", $_SERVER['REMOTE_ADDR'], $message->getName(), $type));
} catch (Exception $e) {
// Message may be already delivered.
// urlopen issue on scalarizr side:
// QueryEnvError: <urlopen error [Errno 4] Interrupted system call>
if (strpos($e->getMessage(), 'Duplicate entry') === false) {
throw $e;
}
}
}
示例11: get
/**
* Gets event list
*
* @param \DateTime $start Start date of the period
* @param \DateTime $end End date of the period
* @param array $criteria optional Filter array ['filterId' => 'value']
* @return ArrayCollection Returns collection of the TimelineEventEntity objects
*/
public function get($start, $end, array $criteria = null)
{
$eventEntity = new TimelineEventEntity();
$joinData = $this->buildJoin($criteria);
$and = '';
if (!empty($criteria['envId'])) {
$and = 'AND e.env_id =' . $criteria['envId'];
} else {
if (!empty($criteria['accountId'])) {
$and = 'AND e.account_id =' . $criteria['accountId'];
}
}
$fields = '';
foreach ($eventEntity->getIterator()->fields() as $field) {
$fields .= ',`' . $field->column->name . '`';
}
$result = $this->db->Execute("\n SELECT " . ltrim($fields, ',') . "\n FROM (\n SELECT " . $eventEntity->fields('e') . "\n FROM " . $eventEntity->table('e') . (isset($joinData['join']) ? $joinData['join'] : '') . "\n WHERE e.dtime BETWEEN " . $eventEntity->qstr('dtime', $start) . " AND " . $eventEntity->qstr('dtime', $end) . " " . $and . "\n " . (isset($joinData['join']) ? "\n UNION\n SELECT " . $eventEntity->fields('e2') . "\n FROM " . $eventEntity->table('e2') . "\n WHERE e2.event_type = " . $eventEntity::EVENT_TYPE_CHANGE_CLOUD_PRICING . "\n AND e2.dtime BETWEEN " . $eventEntity->qstr('dtime', $start) . " AND " . $eventEntity->qstr('dtime', $end) : "") . "\n ) p\n ORDER BY p.dtime DESC\n ");
$events = new ArrayCollection();
while ($record = $result->FetchRow()) {
$item = new TimelineEventEntity();
$item->load($record);
$events->append($item);
}
return $events;
}
示例12: fetchStatusBefore
/**
* Fetches statuses of the previous updates
*/
private function fetchStatusBefore()
{
$this->stateBefore = new \ArrayObject();
//Loads performed updates of MYSQL type
$rs = $this->db->Execute("\n SELECT LOWER(HEX(u.`uuid`)) `uuid`, u.`released`, u.`appears`, u.`applied`, u.`status`, LOWER(HEX(u.`hash`)) `hash`\n FROM `" . self::DB_TABLE_UPGRADES . "` u\n ");
while ($rec = $rs->FetchRow()) {
$entity = new MysqlUpgradeEntity();
$entity->load($rec);
$this->stateBefore[$rec['uuid']] = $entity;
if (isset($entity->appears) && $this->maxDate < $entity->appears) {
$this->maxDate = $entity->appears;
}
}
//Loads updates of FileSystem type
self::checkFilesystemStorage();
//Loads performed updates of Filesystem type
foreach (new FilesystemStorageIterator(self::FS_STORAGE_PATH) as $fileInfo) {
/* @var $fileInfo \SplFileInfo */
if (!$fileInfo->isReadable()) {
throw new Exception\UpgradeException(sprintf('Could not read from file "%s". Lack of access permissions.', $fileInfo->getFilename()));
}
$entity = new FilesystemUpgradeEntity();
$obj = unserialize(file_get_contents($fileInfo->getPathname()));
if (!is_object($obj)) {
throw new Exception\UpgradeException(sprintf('There was error while trying to load record from filesystem storage "%s". Object is expected, %s given', $fileInfo->getPathname(), gettype($obj)));
}
$entity->load($obj);
$this->stateBefore[$entity->uuid] = $entity;
if (isset($entity->appears) && $this->maxDate < $entity->appears) {
$this->maxDate = $entity->appears;
}
unset($obj);
}
}
示例13: getAccountProjects
/**
* Gets available projects for account scope
*
* @param int $accountId Current user object
* @param string $query optional Search criteria
* @return \Scalr\Model\Collections\ArrayCollection
*/
public function getAccountProjects($accountId, $query = null)
{
$collection = $this->findByKey($query, ['accountId' => $accountId], true);
//Select identifiers of all projects assigned to farms from the account
$assignedProjects = [];
$rs = $this->db->Execute("\n SELECT DISTINCT fs.value\n FROM farms f\n JOIN farm_settings fs ON f.id = fs.farmid\n WHERE fs.name = ?\n AND f.clientid = ?\n ", [Entity\FarmSetting::PROJECT_ID, $accountId]);
while ($rec = $rs->fetchRow()) {
$assignedProjects[$rec['value']] = true;
}
//Adjusts missing projects.
//This is going to be very rare event.
foreach ($collection as $projectEntity) {
if (isset($assignedProjects[$projectEntity->projectId])) {
unset($assignedProjects[$projectEntity->projectId]);
}
}
foreach ($assignedProjects as $projectId => $v) {
$project = ProjectEntity::findPk($projectId);
/* @var $project ProjectEntity */
$projectBillingCode = $project->getProperty(ProjectPropertyEntity::NAME_BILLING_CODE);
if (empty($query) || (stripos($project->name, $query) !== false || stripos($projectBillingCode, $query) !== false)) {
$collection->append($project);
}
}
return $collection;
}
示例14: syncValue
/**
* Synchronizes the account level tag value
*
* It does not verify itself whether the cost analytics service is enabled
*
* @param int $accountId The identifier of the client's account
* @param int $tagId The identifier of the clould analytics tag
* @param string $valueId The identifier of the tag's value
* @param string $valueName The name of the tag's value
*/
public function syncValue($accountId, $tagId, $valueId, $valueName)
{
if ($accountId === null) {
$accountId = 0;
}
$tag = AccountTagEntity::findPk($accountId, $tagId, $valueId);
if (!$tag instanceof AccountTagEntity) {
$tag = new AccountTagEntity();
$tag->accountId = $accountId;
$tag->tagId = $tagId;
$tag->valueId = $valueId;
$tag->valueName = $valueName;
} else {
if ($tag->valueName != $valueName) {
$tag->valueName = $valueName;
if ($tagId == TagEntity::TAG_ID_FARM) {
foreach ($this->db->GetAll("\n SELECT fr.id AS farm_role_id, fr.alias\n FROM farm_roles fr\n WHERE fr.farmid = ?\n ", [$valueId]) as $v) {
//Updates all related farm roles
$this->syncValue($accountId, TagEntity::TAG_ID_FARM_ROLE, $v['farm_role_id'], sprintf('%s', $v['alias']));
}
}
} else {
$ignoreupdate = true;
}
}
if (!isset($ignoreupdate)) {
$tag->save();
}
}
示例15: bindSalesOrder
/**
* @param Scalr_Service_ZohoCrm_Entity_SalesOrder $salesOrder
* @param Client $client
* @param int $invoiceId
*/
private function bindSalesOrder($salesOrder, $client, $invoiceId)
{
$invoice = $this->db->GetRow("SELECT * FROM payments WHERE id = ?", array($invoiceId));
$packageId = $client->GetSettingValue(CLIENT_SETTINGS::BILLING_PACKAGE);
$package = $this->db->GetRow("SELECT * FROM billing_packages WHERE id = ?", array($packageId));
$salesOrder->accountId = $client->GetSettingValue(CLIENT_SETTINGS::ZOHOCRM_ACCOUNT_ID);
$salesOrder->subject = sprintf('Monthly fee $%s (%s)', $invoice["amount"], date("F y", strtotime($invoice["dtpaid"])));
$salesOrder->discount = 0;
$salesOrder->tax = 0;
$salesOrder->subTotal = $package["cost"];
$salesOrder->grandTotal = $package["cost"];
$salesOrder->status = "Delivered";
$salesOrder->setProperty(Scalr_Integration_ZohoCrm_CustomFields::PAYMENT_SUBSCRIPTION_ID, $invoice["subscriptionid"]);
// Add product
$productDetail = new Scalr_Service_ZohoCrm_Entity_ProductDetail();
$productDetail->productId = Scalr_Integration_ZohoCrm_CustomFields::$BILLING_PACKAGE_PRODUCT_ID_MAP[$packageId];
$productDetail->quantity = 1;
$productDetail->listPrice = $package["cost"];
$productDetail->discount = 0;
$productDetail->tax = 0;
$productDetail->total = $package["cost"];
$productDetail->totalAfterDiscount = $package["cost"];
$productDetail->netTotal = $package["cost"];
$salesOrder->addProductDetail($productDetail);
}