本文整理汇总了PHP中Mysql::mq方法的典型用法代码示例。如果您正苦于以下问题:PHP Mysql::mq方法的具体用法?PHP Mysql::mq怎么用?PHP Mysql::mq使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mysql
的用法示例。
在下文中一共展示了Mysql::mq方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getUserData
function getUserData($id = null, Mysql $mysql)
{
$user = ['companyId' => 0, 'companyPrivs' => 0];
if (!$id) {
return $user;
}
$query = $mysql->mq('
SELECT
`companyId`,
`companyPrivs`
FROM
`company`
WHERE
`companyId` = ' . (int) $id . '
LIMIT 1
');
return $mysql->assoc($query);
}
示例2: Mysql
header("Cache-Control: public, max-age=1");
require_once $_SERVER['DOCUMENT_ROOT'] . '/functions/system.php';
spl_autoload_register('autoloader');
error_reporting(-1);
$dbConnection = new Mysql();
$dataArray = [];
if (!isset($_GET['type'])) {
exit;
}
if ($_GET['type'] === 'getAll') {
$dataArray = ['categories' => [], 'subCategories' => [], 'metroes' => [], 'cities' => []];
////////////////////////Get all categories
$query = $dbConnection->mq('
SELECT
*
FROM
`categories`
');
if ($query->num_rows) {
while ($result = $dbConnection->assoc($query)) {
$dataArray['categories'][] = ['categoryId' => $result['catId'], 'imageUrl' => $result['catIconUrl'], 'catName' => $result['catName']];
}
}
/////////////////////////Get all subCategories
$query = $dbConnection->mq('
SELECT
*
FROM
`subCategories`
');
if ($query->num_rows) {
示例3: eventsCabinetEdit
function eventsCabinetEdit($userId, Mysql $mysql, $cats = array(), $subCats = array())
{
$getEvents = $mysql->mq('
SELECT
`companyId`,
`eventId`, `eventName`, `eventCode`, `eventInfo`, `eventCondition`,
`eventCatId`, `eventSubCatId`,
`eventOldPrice`, `eventSale`, `eventSaleText`,
`eventCatId`, `eventSubCatId`, `eventStartDate`, `eventEndDate`,
`eventStopped` ,`spotId`, `spotName`,
IF(`eventImage`="", "/img/addUserImage.jpg",`eventImage`) as `eventImage`,
`eventOldPrice` - (`eventOldPrice` * (`eventSale`/100)) as `eventNewPrice`,
IF(`eventEndDate` < NOW() OR `eventStopped` = 1 , "" , " active") as eventActivity,
IF(`companyUpInCategory`>0,"active","") as upInCategory,
IF(`companyUpInAllCategories`>0,"active","") as upInAllCategories,
`companyUpInCategory`, `companyUpInAllCategories`,
IF(`eventFreezeTime`>=NOW(),"active", "") as frozen
FROM
`event`
LEFT JOIN
`eventSpots`
ON
`eventId` = `eventSpotsEventId`
LEFT JOIN
`spots`
ON
`eventSpotsSpotId` = `spotId`
LEFT JOIN
`company`
ON
`companyId` = `eventCompanyId`
WHERE
`eventCompanyId` = ' . $userId . '
ORDER BY
`eventId` DESC
');
$ups = '';
$eventId = null;
$showEvents = [];
$spotsList = [];
$displayEvents = [];
$spotsNames = [];
$spotsToCheckbox = [];
$spotsIds = [];
$getSpotsList = $mysql->mq('
SELECT
`spotId`,`spotName`
FROM
`spots`
WHERE
`spotCompanyId` = ' . $userId . '
');
if ($getSpotsList->num_rows) {
while ($result = $mysql->assoc($getSpotsList)) {
$spotsList[$result['spotId']] = $result['spotName'];
}
}
if ($getEvents->num_rows) {
for ($i = 0; $result = $mysql->assoc($getEvents); $i++) {
if (!$eventId || $eventId != $result['eventId']) {
if (!is_null($eventId)) {
$showEvents[] = $result;
$eventId = $result['eventId'];
} else {
$showEvents[] = $result;
$eventId = $result['eventId'];
}
}
$spotsToCheckbox[$eventId][$result['spotId']] = $result['spotName'];
$spotsNames[$eventId][] = $result['spotName'];
$spotsIds[$eventId][] = $result['spotId'];
if ($i == 0) {
$ups = '<script>companyUpInCat=' . $result['companyUpInCategory'] . '; companyUpInAllCat=' . $result['companyUpInAllCategories'] . ';</script>';
}
}
}
ob_start();
echo '<div>';
for ($i = 0; $i < count($showEvents); $i++) {
$class = '';
$wrapper = '';
$showEvents[$i]['spotsName'] = implode(', ', $spotsNames[$showEvents[$i]['eventId']]);
$showEvents[$i]['spots'] = arrayToCheckbox($spotsList, $spotsIds[$showEvents[$i]['eventId']], ' class="checkboxLabel"', ' name="eventSpotsSpotId[]"');
$showEvents[$i]['cats'] = arrayToSelect($cats, $showEvents[$i]['eventCatId'], '<option value="0">Категория</option>', 'name="eventCatId"');
$showEvents[$i]['subCats'] = arrayToSelect($subCats[$showEvents[$i]['eventCatId']], $showEvents[$i]['eventSubCatId'], '<option value="0">Категория</option>', 'name="eventSubCatId"');
if ($i % 2 != 0) {
$class = 'second';
$wrapper = '<div class="clear"></div></div><div>';
}
require $_SERVER['DOCUMENT_ROOT'] . '/pagesTemplates/eventsEdit.php';
echo $wrapper;
}
echo '</div>';
return ob_get_clean() . $ups;
}