/**
  * @inheritDoc IElementType::modifyElementsQuery()
  *
  * @param DbCommand $query
  * @param ElementCriteriaModel $criteria
  *
  * @return mixed
  */
 public function modifyElementsQuery(DbCommand $query, ElementCriteriaModel $criteria)
 {
     $query->addSelect('globalsets.name, globalsets.handle, globalsets.fieldLayoutId')->join('globalsets globalsets', 'globalsets.id = elements.id');
     if ($criteria->handle) {
         $query->andWhere(DbHelper::parseParam('globalsets.handle', $criteria->handle, $query->params));
     }
 }
    public function modifyElementsQuery(DbCommand $query, ElementCriteriaModel $criteria)
    {
        $query->addSelect('
				neoblocks.fieldId,
				neoblocks.ownerId,
				neoblocks.ownerLocale,
				neoblocks.typeId,
				neoblocks.collapsed
			')->join('neoblocks neoblocks', 'neoblocks.id = elements.id')->leftJoin('neoblockstructures neoblockstructures', ['and', 'neoblockstructures.ownerId = neoblocks.ownerId', 'neoblockstructures.fieldId = neoblocks.fieldId', ['or', 'neoblockstructures.ownerLocale = neoblocks.ownerLocale', ['and', 'neoblockstructures.ownerLocale is null', 'neoblocks.ownerLocale is null']]])->leftJoin('structureelements structureelements', ['and', 'structureelements.structureId = neoblockstructures.structureId', 'structureelements.elementId = neoblocks.id']);
        if ($criteria->fieldId) {
            $query->andWhere(DbHelper::parseParam('neoblocks.fieldId', $criteria->fieldId, $query->params));
        }
        if ($criteria->ownerId) {
            $query->andWhere(DbHelper::parseParam('neoblocks.ownerId', $criteria->ownerId, $query->params));
        }
        if ($criteria->ownerLocale) {
            $query->andWhere(DbHelper::parseParam('neoblocks.ownerLocale', $criteria->ownerLocale, $query->params));
        }
        if ($criteria->typeId) {
            $query->andWhere(DbHelper::parseParam('neoblocks.typeId', $criteria->typeId, $query->params));
        } else {
            if ($criteria->type) {
                $query->join('neoblocktypes neoblocktypes', 'neoblocktypes.id = neoblocks.typeId');
                $query->andWhere(DbHelper::parseParam('neoblocktypes.handle', $criteria->type, $query->params));
            }
        }
    }
 private static function importSales($file)
 {
     $error = array();
     $row = 0;
     if (($handle = fopen($file['tmp_name'], "r")) !== false) {
         $cols = array(SALE_ORDER_NUMBER, SALE_ORDER_CHARGED_DATE, SALE_ORDER_CHARGED_TIMESTAMP, SALE_FINANCIAL_STATUS, SALE_DEVICE_MODEL, SALE_PRODUCT_TITLE, SALE_PRODUCT_ID, SALE_PRODUCT_TYPE, SALE_SKU_ID, SALE_CURRENCY_CODE, SALE_ITEM_PRICE, SALE_TAXES_COLLECTED, SALE_CHARGED_AMOUNT, SALE_BUYER_CITY, SALE_BUYER_STATE, SALE_BUYER_POSTAL_CODE, SALE_BUYER_COUNTRY, SALE_APP_ID);
         while (($data = fgetcsv($handle, 1000, ",")) !== false) {
             if ($row > 0) {
                 $rowCount = count($data);
                 if ($rowCount != CHECKOUT_SALES_FILE_COL_COUNT) {
                     $error[] = 'Row #' . $row . ' has invalid column count ' . $rowCount . '/' . CHECKOUT_SALES_FILE_COL_COUNT;
                 } else {
                     $values = array();
                     for ($colIdx = 0; $colIdx < $rowCount; ++$colIdx) {
                         $values[$cols[$colIdx]] = $data[$colIdx];
                     }
                 }
                 $res = DbHelper::insertSale($values);
                 if ($res != null) {
                     $error[] = 'Row #' . $row . ' insertion failed : ' . $res;
                 }
             }
             ++$row;
         }
         fclose($handle);
     }
     return $error;
 }
 public function modifyElementsQuery(DbCommand $query, ElementCriteriaModel $criteria)
 {
     $query->addSelect('formbuilder_entries.formId, formbuilder_entries.title, formbuilder_entries.data')->join('formbuilder_entries formbuilder_entries', 'formbuilder_entries.id = elements.id');
     if ($criteria->formId) {
         $query->andWhere(DbHelper::parseParam('formbuilder_entries.formId', $criteria->formId, $query->params));
     }
 }
 public static function addtoNewsLetterSubscriptionList($email = '')
 {
     global $tableprefix;
     if (!empty($email)) {
         // Check email address exists in subscribers list
         $resCat = DbHelper::execute("SELECT nId FROM " . $tableprefix . "newsletter_subscribers WHERE vEmail ='" . mysql_real_escape_string($email) . "' ");
         $data = DbHelper::fetchOne($resCat);
         // If alraedy exists return false
         if ($data) {
             $emailSubscribed = 'exists';
         } else {
             // Insert Email id to subscriberlist
             $resInsert = DbHelper::execute("INSERT INTO " . $tableprefix . "newsletter_subscribers\n                                                (vEmail)VALUES('" . mysql_real_escape_string($email) . "')");
             $constantcontactSettings = getconstantcontactSettings();
             $_SESSION['constantaction'] = 'Add Email';
             $userinfo = array();
             $userinfo['emailAddress'] = mysql_real_escape_string($email);
             $userinfo['firstName'] = '';
             $userinfo['lastName'] = '';
             $userinfo['lists'] = array($constantcontactSettings['constantcontactlistId']);
             $_SESSION['constantparam']['redirecturl'] = SITE_URL . '/checkout.php';
             //header("location:".$constantcontactSettings['verificationURL']);
             $emailSubscribed = 'added';
         }
         return $emailSubscribed;
     }
 }
 public function defineContentAttribute()
 {
     $maxLength = $this->getSettings()->maxLength;
     if (!$maxLength) {
         $columnType = ColumnType::Text;
     } else {
         $columnType = DbHelper::getTextualColumnTypeByContentLength($maxLength);
     }
     return array(AttributeType::String, 'column' => $columnType, 'maxLength' => $maxLength);
 }
 public function modifyElementsQuery(DbCommand $query, ElementCriteriaModel $criteria)
 {
     $query->addSelect('submissions.formId')->join('formerly_submissions submissions', 'submissions.id = elements.id');
     if ($criteria->formId) {
         $query->andWhere(DbHelper::parseParam('submissions.formId', $criteria->formId, $query->params));
     }
     if ($criteria->form) {
         $query->join('formerly_forms forms', 'forms.id = submissions.formId');
         $query->andWhere(DbHelper::parseParam('formerly_forms.handle', $criteria->form, $query->params));
     }
 }
 /**
  * Save a list of models, each model may be inserted or updated depend on its existence.
  * This method could be used to achieve better performance during insertion/update of the large
  * amount of data to the database table.
  * @param \yii\db\ActiveRecord[] $models list of models to be saved.
  * If a key is not a valid column name, the corresponding value will be ignored.
  * @param array $attributeNames name list of attributes that need to be update. Defaults to empty,
  * meaning all fields of corresponding active record will be saved.
  * This parameter is ignored in the case of insertion
  * @param int $mode the save mode flag.
  * If this flag value is set to 0, any model that have a PK value is NULL will be inserted, otherwise it will be update.
  * If this flag value is set to 1, all models will be inserted regardless to PK values.
  * If this flag value is set to 2, all models will be updated regardless to PK values
  * @return \stdClass An instance of stdClass that may have one of the following fields:
  * - The 'lastId' field is the last model ID (auto-incremental primary key) inserted.
  * - The 'insertCount' is the number of rows inserted.
  * - The 'updateCount' is the number of rows updated.
  */
 public static function batchSave($models, $attributeNames = [], $mode = DbHelper::SAVE_MODE_AUTO)
 {
     $returnModels = [];
     $a = DbHelper::batchSave($models, $attributeNames, $mode, $returnModels);
     if (isset($a)) {
         $insertModels = isset($returnModels['inserted']) ? $returnModels['inserted'] : null;
         $updateModels = isset($returnModels['updated']) ? $returnModels['updated'] : null;
         static::afterBatchSave($attributeNames, $mode, $insertModels, $updateModels);
     }
     return $a;
 }
Beispiel #9
0
 /**
  * Connect to the database
  *
  * @return bool false on failure / mysqli MySQLi object instance on success
  */
 public function connect()
 {
     // Try and connect to the database
     if (!isset(self::$connection)) {
         // Load configuration as an array. Use the actual location of your configuration file
         $config = parse_ini_file('config.ini');
         self::$connection = new mysqli('localhost', $config['username'], $config['password'], $config['dbname']);
     }
     // If connection was not successful, handle the error
     if (self::$connection === false) {
         // Handle error - notify administrator, log to a file, show an error screen, etc.
         return false;
     }
     return self::$connection;
 }
Beispiel #10
0
 public function __construct(ConnectionInterface $db, $table, array $fields, $isTemp = true)
 {
     if (!$table) {
         throw new ImporterException('Не задана таблица для импорта');
     }
     if (!$fields) {
         throw new ImporterException('Не заданы поля для импорта.');
     }
     $this->db = $db;
     $this->fields = $fields;
     $this->table = $table;
     if ($isTemp) {
         $this->table .= '_xml_importer';
         DbHelper::createTable($this->db, $this->table, $this->fields, $isTemp);
     }
 }
 /**
  * Any migration code in here is wrapped inside of a transaction.
  *
  * @return bool
  */
 public function safeUp()
 {
     if (!craft()->db->tableExists('searchindex')) {
         // Taking the scenic route here so we can get to MysqlSchema's $engine argument
         $table = DbHelper::addTablePrefix('searchindex');
         $columns = array('elementId' => DbHelper::generateColumnDefinition(array('column' => ColumnType::Int, 'null' => false)), 'attribute' => DbHelper::generateColumnDefinition(array('column' => ColumnType::Varchar, 'maxLength' => 25, 'null' => false)), 'fieldId' => DbHelper::generateColumnDefinition(array('column' => ColumnType::Int, 'null' => false)), 'locale' => DbHelper::generateColumnDefinition(array('column' => ColumnType::Locale, 'null' => false)), 'keywords' => DbHelper::generateColumnDefinition(array('column' => ColumnType::Text, 'null' => false)));
         $this->execute(craft()->db->getSchema()->createTable($table, $columns, null, 'MyISAM'));
         // Give it a composite primary key
         $this->addPrimaryKey('searchindex', 'elementId,attribute,fieldId,locale');
         // Add the FULLTEXT index on `keywords`
         $this->execute('CREATE FULLTEXT INDEX ' . craft()->db->quoteTableName(DbHelper::getIndexName('searchindex', 'keywords')) . ' ON ' . craft()->db->quoteTableName($table) . ' ' . '(' . craft()->db->quoteColumnName('keywords') . ')');
         Craft::log('Successfully added the `searchindex` table with a fulltext index on `keywords`.', LogLevel::Info, true);
     } else {
         Craft::log('Tried to add the `searchindex` table, but it already exists.', LogLevel::Warning, true);
     }
     return true;
 }
 public function modifyElementsQuery(DbCommand $query, ElementCriteriaModel $criteria)
 {
     $query->addSelect('supertableblocks.fieldId, supertableblocks.ownerId, supertableblocks.ownerLocale, supertableblocks.typeId, supertableblocks.sortOrder')->join('supertableblocks supertableblocks', 'supertableblocks.id = elements.id');
     if ($criteria->fieldId) {
         $query->andWhere(DbHelper::parseParam('supertableblocks.fieldId', $criteria->fieldId, $query->params));
     }
     if ($criteria->ownerId) {
         $query->andWhere(DbHelper::parseParam('supertableblocks.ownerId', $criteria->ownerId, $query->params));
     }
     if ($criteria->ownerLocale) {
         $query->andWhere(DbHelper::parseParam('supertableblocks.ownerLocale', $criteria->ownerLocale, $query->params));
     }
     if ($criteria->type) {
         $query->join('supertableblocktypes supertableblocktypes', 'supertableblocktypes.id = supertableblocks.typeId');
         $query->andWhere(DbHelper::parseParam('supertableblocktypes.handle', $criteria->type, $query->params));
     }
 }
 public static function checkCouponcodeExists($couponcode = '', $userId = "")
 {
     global $tableprefix;
     $currentDate = date('Y-m-d');
     if (!empty($couponcode)) {
         // Check email address exists in subscribers list
         $query = "SELECT o.couponCode FROM " . $tableprefix . "orders o\n                        WHERE  o.user_id = '" . mysql_real_escape_string($userId) . "' AND\n                              o.couponCode ='" . mysql_real_escape_string($couponcode) . "'  ";
         $resCat = DbHelper::execute($query);
         if (mysql_num_rows($resCat) == 0) {
             $query = "SELECT cc.* FROM " . $tableprefix . "couponcode cc WHERE cc.ccCode='" . mysql_real_escape_string($couponcode) . "' AND\n                              cc.ccStatus='Y' AND cc.subscriptionStatus='Y'\n                              AND cc.ccStartDate<='" . mysql_real_escape_string($currentDate) . "' AND\n                              cc.ccEndDate>='" . mysql_real_escape_string($currentDate) . "'";
             $resCat = DbHelper::execute($query);
             $data = DbHelper::fetchRow($resCat);
         }
         // If couopon code valid then return coupon percenatage
         if ($data) {
             return $data;
         }
     }
 }
 /**
  * @inheritDoc IFieldType::defineContentAttribute()
  *
  * @return mixed
  */
 public function defineContentAttribute()
 {
     if ($this->multi) {
         $options = $this->getSettings()->options;
         // See how much data we could possibly be saving if everything was selected.
         $length = 0;
         foreach ($options as $option) {
             if (!empty($option['value'])) {
                 // +3 because it will be json encoded. Includes the surrounding quotes and comma.
                 $length += strlen($option['value']) + 3;
             }
         }
         if ($length) {
             // Add +2 for the outer brackets and -1 for the last comma.
             $length += 1;
             $columnType = DbHelper::getTextualColumnTypeByContentLength($length);
         } else {
             $columnType = ColumnType::Varchar;
         }
         return array(AttributeType::Mixed, 'column' => $columnType, 'default' => $this->getDefaultValue());
     } else {
         return array(AttributeType::String, 'column' => ColumnType::Varchar, 'maxLength' => 255, 'default' => $this->getDefaultValue());
     }
 }
 /**
  * @inheritDoc IElementType::modifyElementsQuery()
  *
  * @param DbCommand            $query
  * @param ElementCriteriaModel $criteria
  *
  * @return bool|false|null|void
  */
 public function modifyElementsQuery(DbCommand $query, ElementCriteriaModel $criteria)
 {
     $query->addSelect('entries.sectionId, entries.typeId, entries.authorId, entries.postDate, entries.expiryDate')->join('entries entries', 'entries.id = elements.id')->join('sections sections', 'sections.id = entries.sectionId')->leftJoin('structures structures', 'structures.id = sections.structureId')->leftJoin('structureelements structureelements', array('and', 'structureelements.structureId = structures.id', 'structureelements.elementId = entries.id'));
     if ($criteria->ref) {
         $refs = ArrayHelper::stringToArray($criteria->ref);
         $conditionals = array();
         foreach ($refs as $ref) {
             $parts = array_filter(explode('/', $ref));
             if ($parts) {
                 if (count($parts) == 1) {
                     $conditionals[] = DbHelper::parseParam('elements_i18n.slug', $parts[0], $query->params);
                 } else {
                     $conditionals[] = array('and', DbHelper::parseParam('sections.handle', $parts[0], $query->params), DbHelper::parseParam('elements_i18n.slug', $parts[1], $query->params));
                 }
             }
         }
         if ($conditionals) {
             if (count($conditionals) == 1) {
                 $query->andWhere($conditionals[0]);
             } else {
                 array_unshift($conditionals, 'or');
                 $query->andWhere($conditionals);
             }
         }
     }
     if ($criteria->type) {
         $typeIds = array();
         if (!is_array($criteria->type)) {
             $criteria->type = array($criteria->type);
         }
         foreach ($criteria->type as $type) {
             if (is_numeric($type)) {
                 $typeIds[] = $type;
             } else {
                 if (is_string($type)) {
                     $types = craft()->sections->getEntryTypesByHandle($type);
                     if ($types) {
                         foreach ($types as $type) {
                             $typeIds[] = $type->id;
                         }
                     } else {
                         return false;
                     }
                 } else {
                     if ($type instanceof EntryTypeModel) {
                         $typeIds[] = $type->id;
                     } else {
                         return false;
                     }
                 }
             }
         }
         $query->andWhere(DbHelper::parseParam('entries.typeId', $typeIds, $query->params));
     }
     if ($criteria->postDate) {
         $query->andWhere(DbHelper::parseDateParam('entries.postDate', $criteria->postDate, $query->params));
     } else {
         if ($criteria->after) {
             $query->andWhere(DbHelper::parseDateParam('entries.postDate', '>=' . $criteria->after, $query->params));
         }
         if ($criteria->before) {
             $query->andWhere(DbHelper::parseDateParam('entries.postDate', '<' . $criteria->before, $query->params));
         }
     }
     if ($criteria->expiryDate) {
         $query->andWhere(DbHelper::parseDateParam('entries.expiryDate', $criteria->expiryDate, $query->params));
     }
     if ($criteria->editable) {
         $user = craft()->userSession->getUser();
         if (!$user) {
             return false;
         }
         // Limit the query to only the sections the user has permission to edit
         $editableSectionIds = craft()->sections->getEditableSectionIds();
         $query->andWhere(array('in', 'entries.sectionId', $editableSectionIds));
         // Enforce the editPeerEntries permissions for non-Single sections
         $noPeerConditions = array();
         foreach (craft()->sections->getEditableSections() as $section) {
             if ($section->type != SectionType::Single && !$user->can('editPeerEntries:' . $section->id)) {
                 $noPeerConditions[] = array('or', 'entries.sectionId != ' . $section->id, 'entries.authorId = ' . $user->id);
             }
         }
         if ($noPeerConditions) {
             array_unshift($noPeerConditions, 'and');
             $query->andWhere($noPeerConditions);
         }
     }
     if ($criteria->section) {
         if ($criteria->section instanceof SectionModel) {
             $criteria->sectionId = $criteria->section->id;
             $criteria->section = null;
         } else {
             $query->andWhere(DbHelper::parseParam('sections.handle', $criteria->section, $query->params));
         }
     }
     if ($criteria->sectionId) {
         $query->andWhere(DbHelper::parseParam('entries.sectionId', $criteria->sectionId, $query->params));
     }
     if (craft()->getEdition() >= Craft::Client) {
         if ($criteria->authorId) {
             $query->andWhere(DbHelper::parseParam('entries.authorId', $criteria->authorId, $query->params));
         }
         if ($criteria->authorGroupId || $criteria->authorGroup) {
             $query->join('usergroups_users usergroups_users', 'usergroups_users.userId = entries.authorId');
             if ($criteria->authorGroupId) {
                 $query->andWhere(DbHelper::parseParam('usergroups_users.groupId', $criteria->authorGroupId, $query->params));
             }
             if ($criteria->authorGroup) {
                 $query->join('usergroups usergroups', 'usergroups.id = usergroups_users.groupId');
                 $query->andWhere(DbHelper::parseParam('usergroups.handle', $criteria->authorGroup, $query->params));
             }
         }
     }
 }
Beispiel #16
0
<?php

defined('DIRECT_ACCESS_CHECK') or die('DIRECT ACCESS NOT ALLOWED');
/**
 * Copyright (c) 2013 EIRL DEVAUX J. - Medialoha.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl.html
 *
 * Contributors:
 *     EIRL DEVAUX J. - Medialoha - initial API and implementation
 */
// get reports preferences
$cfg = CfgHelper::getInstance();
$mAppArr = DbHelper::selectRows(TBL_APPLICATIONS, null, APP_NAME . ' ASC', '*', null, null, false);
$mSelectedAppId = $mNavCtl->getParam('app', '-1');
$mSelectedAppName = "All Applications";
$mSelectedAppPackage = null;
// build applications dropdown items array
$mDropdownItems = array('<li><a href="#" onclick="setSelectedAppId(this, -1)" >All Applications</a></li>');
foreach ($mAppArr as $app) {
    $mDropdownItems[] = '<li><a href="#" onclick="setSelectedAppId(this, ' . $app[APP_ID] . ')" >' . $app[APP_NAME] . '</a></li>';
    if ($mSelectedAppId == $app[APP_ID]) {
        $mSelectedAppName = $app[APP_NAME];
        $mSelectedAppPackage = $app[APP_PACKAGE];
    }
}
?>
<div class="navbar">
  <div class="navbar-inner">
Beispiel #17
0
<?php

$app->get('/courses', function () {
    $db = new DbHelper();
    $columns = "ID,title,description,price,start_date,end_date,max_number_of_students,ID_subject";
    $table = "course";
    $where = array();
    $orwhere = array();
    //$limit = 1;
    $result = $db->select($table, $columns, $where, $orwhere);
    echoResponse(200, $result);
});
 /**
  * @inheritDoc BaseFieldType::validate()
  *
  * @param mixed $value
  *
  * @return true|string|array
  */
 public function validate($value)
 {
     $settings = $this->getSettings();
     // This wasn't always a setting.
     $columnType = !$settings->getAttribute('columnType') ? ColumnType::Text : $settings->getAttribute('columnType');
     $postContentSize = strlen($value);
     $maxDbColumnSize = DbHelper::getTextualColumnStorageCapacity($columnType);
     // Give ourselves 10% wiggle room.
     $maxDbColumnSize = ceil($maxDbColumnSize * 0.9);
     if ($postContentSize > $maxDbColumnSize) {
         // Give ourselves 10% wiggle room.
         $maxDbColumnSize = ceil($maxDbColumnSize * 0.9);
         if ($postContentSize > $maxDbColumnSize) {
             return Craft::t('{attribute} is too long.', array('attribute' => Craft::t($this->model->name)));
         }
     }
     return true;
 }
 /**
  * @inheritDoc IFieldType::modifyElementsQuery()
  *
  * @param DbCommand $query
  * @param mixed     $value
  *
  * @return null|false
  */
 public function modifyElementsQuery(DbCommand $query, $value)
 {
     if ($value !== null) {
         if ($this->defineContentAttribute()) {
             $handle = $this->model->handle;
             $query->andWhere(DbHelper::parseParam('content.' . craft()->content->fieldColumnPrefix . $handle, $value, $query->params));
         } else {
             return false;
         }
     }
 }
Beispiel #20
0
 /**
  * Constructor
  */
 public function __construct()
 {
     parent::__construct();
     // force PHP internal encoding as UTF 8
     mb_internal_encoding("UTF-8");
 }
 /**
  * @param $groupIds
  *
  * @return array
  */
 private function _getUserIdsByGroupIds($groupIds)
 {
     $query = craft()->db->createCommand()->select('userId')->from('usergroups_users');
     $query->where(DbHelper::parseParam('groupId', $groupIds, $query->params));
     return $query->queryColumn();
 }
 /**
  * Returns a DbCommand instance ready to search for elements based on a given element criteria.
  *
  * @param mixed &$criteria
  * @return DbCommand|false
  */
 public function buildElementsQuery(&$criteria = null)
 {
     if (!$criteria instanceof ElementCriteriaModel) {
         $criteria = $this->getCriteria('Entry', $criteria);
     }
     $elementType = $criteria->getElementType();
     $query = craft()->db->createCommand()->select('elements.id, elements.type, elements.enabled, elements.archived, elements.dateCreated, elements.dateUpdated, elements_i18n.locale, elements_i18n.uri')->from('elements elements');
     if ($elementType->hasTitles() && $criteria) {
         $query->addSelect('content.title');
         $query->join('content content', 'content.elementId = elements.id');
     }
     $query->leftJoin('elements_i18n elements_i18n', 'elements_i18n.elementId = elements.id');
     if ($elementType->isTranslatable()) {
         // Locale conditions
         if (!$criteria->locale) {
             $criteria->locale = craft()->language;
         }
         $localeIds = array_unique(array_merge(array($criteria->locale), craft()->i18n->getSiteLocaleIds()));
         $quotedLocaleColumn = craft()->db->quoteColumnName('elements_i18n.locale');
         if (count($localeIds) == 1) {
             $query->andWhere('elements_i18n.locale = :locale');
             $query->params[':locale'] = $localeIds[0];
         } else {
             $quotedLocales = array();
             $localeOrder = array();
             foreach ($localeIds as $localeId) {
                 $quotedLocale = craft()->db->quoteValue($localeId);
                 $quotedLocales[] = $quotedLocale;
                 $localeOrder[] = "({$quotedLocaleColumn} = {$quotedLocale}) DESC";
             }
             $query->andWhere("{$quotedLocaleColumn} IN (" . implode(', ', $quotedLocales) . ')');
             $query->order($localeOrder);
         }
     }
     // The rest
     if ($criteria->id) {
         $query->andWhere(DbHelper::parseParam('elements.id', $criteria->id, $query->params));
     }
     if ($criteria->uri !== null) {
         $query->andWhere(DbHelper::parseParam('elements_i18n.uri', $criteria->uri, $query->params));
     }
     if ($criteria->archived) {
         $query->andWhere('elements.archived = 1');
     } else {
         $query->andWhere('elements.archived = 0');
         if ($criteria->status) {
             $statusConditions = array();
             $statuses = ArrayHelper::stringToArray($criteria->status);
             foreach ($statuses as $status) {
                 $status = strtolower($status);
                 switch ($status) {
                     case BaseElementModel::ENABLED:
                         $statusConditions[] = 'elements.enabled = 1';
                         break;
                     case BaseElementModel::DISABLED:
                         $statusConditions[] = 'elements.enabled = 0';
                     default:
                         // Maybe the element type supports another status?
                         $elementStatusCondition = $elementType->getElementQueryStatusCondition($query, $status);
                         if ($elementStatusCondition) {
                             $statusConditions[] = $elementStatusCondition;
                         } else {
                             if ($elementStatusCondition === false) {
                                 return false;
                             }
                         }
                 }
             }
             if ($statusConditions) {
                 if (count($statusConditions) == 1) {
                     $statusCondition = $statusConditions[0];
                 } else {
                     array_unshift($statusConditions, 'or');
                     $statusCondition = $statusConditions;
                 }
                 $query->andWhere($statusCondition);
             }
         }
     }
     if ($criteria->dateCreated) {
         $query->andWhere(DbHelper::parseDateParam('elements.dateCreated', '=', $criteria->dateCreated, $query->params));
     }
     if ($criteria->dateUpdated) {
         $query->andWhere(DbHelper::parseDateParam('elements.dateUpdated', '=', $criteria->dateUpdated, $query->params));
     }
     if ($criteria->parentOf) {
         list($childIds, $fieldIds) = $this->_normalizeRelationParams($criteria->parentOf, $criteria->parentField);
         $query->join('relations parents', 'parents.parentId = elements.id');
         $query->andWhere(DbHelper::parseParam('parents.childId', $childIds, $query->params));
         if ($fieldIds) {
             $query->andWhere(DbHelper::parseParam('parents.fieldId', $fieldIds, $query->params));
         }
     }
     if ($criteria->childOf) {
         list($parentIds, $fieldIds) = $this->_normalizeRelationParams($criteria->childOf, $criteria->childField);
         $query->join('relations children', 'children.childId = elements.id');
         $query->andWhere(DbHelper::parseParam('children.parentId', $parentIds, $query->params));
     }
     if ($elementType->modifyElementsQuery($query, $criteria) !== false) {
         return $query;
     } else {
         return false;
     }
 }
 /**
  * Modifies an element query targeting elements of this type.
  *
  * @param DbCommand $query
  * @param ElementCriteriaModel $criteria
  * @return mixed
  */
 public function modifyElementsQuery(DbCommand $query, ElementCriteriaModel $criteria)
 {
     $query->addSelect('events.calendarId, events.startDate, events.endDate')->join('events events', 'events.id = elements.id');
     if ($criteria->calendarId) {
         $query->andWhere(DbHelper::parseParam('events.calendarId', $criteria->calendarId, $query->params));
     }
     if ($criteria->calendar) {
         $query->join('events_calendars events_calendars', 'events_calendars.id = events.calendarId');
         $query->andWhere(DbHelper::parseParam('events_calendars.handle', $criteria->calendar, $query->params));
     }
     if ($criteria->startDate) {
         $query->andWhere(DbHelper::parseDateParam('events.startDate', $criteria->startDate, $query->params));
     }
     if ($criteria->endDate) {
         $query->andWhere(DbHelper::parseDateParam('events.endDate', $criteria->endDate, $query->params));
     }
 }
Beispiel #24
0
 /**
  * @param      $table
  * @param      $column
  * @param      $type
  * @param null $newName
  * @param null $after
  *
  * @return int
  */
 public function alterColumn($table, $column, $type, $newName = null, $after = null)
 {
     $table = $this->getConnection()->addTablePrefix($table);
     $type = DbHelper::generateColumnDefinition($type);
     return $this->setText($this->getConnection()->getSchema()->alterColumn($table, $column, $type, $newName, $after))->execute();
 }
Beispiel #25
0
 /**
  * Creates the searchindex table.
  *
  * @return null
  */
 private function _createSearchIndexTable()
 {
     Craft::log('Creating the searchindex table.');
     // Taking the scenic route here so we can get to MysqlSchema's $engine argument
     $table = craft()->db->addTablePrefix('searchindex');
     $columns = array('elementId' => DbHelper::generateColumnDefinition(array('column' => ColumnType::Int, 'null' => false)), 'attribute' => DbHelper::generateColumnDefinition(array('column' => ColumnType::Varchar, 'maxLength' => 25, 'null' => false)), 'fieldId' => DbHelper::generateColumnDefinition(array('column' => ColumnType::Int, 'null' => false)), 'locale' => DbHelper::generateColumnDefinition(array('column' => ColumnType::Locale, 'null' => false)), 'keywords' => DbHelper::generateColumnDefinition(array('column' => ColumnType::Text, 'null' => false)));
     craft()->db->createCommand()->setText(craft()->db->getSchema()->createTable($table, $columns, null, 'MyISAM'))->execute();
     // Give it a composite primary key
     craft()->db->createCommand()->addPrimaryKey('searchindex', 'elementId,attribute,fieldId,locale');
     // Add the FULLTEXT index on `keywords`
     craft()->db->createCommand()->setText('CREATE FULLTEXT INDEX ' . craft()->db->quoteTableName(craft()->db->getIndexName('searchindex', 'keywords')) . ' ON ' . craft()->db->quoteTableName($table) . ' ' . '(' . craft()->db->quoteColumnName('keywords') . ')')->execute();
     Craft::log('Finished creating the searchindex table.');
 }
Beispiel #26
0
							<dd id="milestoneView" >
								<?php 
    $m->printOverview();
    ?>
								<a href="javascript:editIssueMilestone()" >&nbsp;<i class="icon-pencil" ></i>&nbsp;</a>
							</dd>
							<?php 
}
?>
							<dd id="milestoneEdit" style="<?php 
echo !is_null($m) ? 'display:none' : '';
?>
" >
								
								<?php 
$arr = DbHelper::selectRows(TBL_MILESTONES, MILE_APP_ID . '=' . $issue->issue_app_id, MILE_DUEDATE . ' ASC', MILE_ID . ', ' . MILE_NAME);
if (empty($arr)) {
    echo '<span class="muted text-i" >No milestone found</span>';
} else {
    echo '<select name="new_milestone" ><option value="null" >No milestone</option>';
    foreach ($arr as $mile) {
        ?>
<option value="<?php 
        echo $mile->mile_id;
        ?>
" <?php 
        if ($mile->mile_id == $issue->issue_milestone_id) {
            echo 'selected="selected"';
        }
        ?>
 ><?php 
 /**
  * Escapes commas and asterisks in a string so they are not treated as special characters in
  * {@link DbHelper::parseParam()}.
  *
  * @param string $value The param value.
  *
  * @return string The escaped param value.
  */
 public function literalFilter($value)
 {
     return DbHelper::escapeParam($value);
 }
 /**
  * Modifies an element query targeting elements of this type.
  *
  * @param DbCommand $query
  * @param ElementCriteriaModel $criteria
  * @return mixed
  */
 public function modifyElementsQuery(DbCommand $query, ElementCriteriaModel $criteria)
 {
     $query->addSelect('forms.id,
                        forms.fieldLayoutId,
                        forms.redirectEntryId,
                        forms.name,
                        forms.handle,
                        forms.titleFormat,
                        forms.submitAction,
                        forms.submitButton,
                        forms.afterSubmit,
                        forms.afterSubmitText,
                        forms.submissionEnabled,
                        forms.displayTabTitles,
                        forms.redirectUrl,
                        forms.sendCopy,
                        forms.sendCopyTo,
                        forms.notificationEnabled,
                        forms.notificationFilesEnabled,
                        forms.notificationRecipients,
                        forms.notificationSubject,
                        forms.confirmationSubject,
                        forms.notificationSenderName,
                        forms.confirmationSenderName,
                        forms.notificationSenderEmail,
                        forms.confirmationSenderEmail,
                        forms.notificationReplyToEmail,
                        forms.formTemplate,
                        forms.tabTemplate,
                        forms.fieldTemplate,
                        forms.notificationTemplate,
                        forms.confirmationTemplate');
     $query->join('amforms_forms forms', 'forms.id = elements.id');
     if ($criteria->handle) {
         $query->andWhere(DbHelper::parseParam('forms.handle', $criteria->handle, $query->params));
     }
 }
 /**
  * Modifies an entries query targeting entries of this type.
  *
  * @param DbCommand $query
  * @param ElementCriteriaModel $criteria
  * @return mixed
  */
 public function modifyElementsQuery(DbCommand $query, ElementCriteriaModel $criteria)
 {
     $query->addSelect('tags.setId, tags.name')->join('tags tags', 'tags.id = elements.id');
     if ($criteria->name) {
         $query->andWhere(DbHelper::parseParam('tags.name', $criteria->name, $query->params));
     }
     if ($criteria->setId) {
         $query->andWhere(DbHelper::parseParam('tags.setId', $criteria->setId, $query->params));
     }
     if ($criteria->set) {
         $query->join('tagsets tagsets', 'tagsets.id = tags.setId');
         $query->andWhere(DbHelper::parseParam('tagsets.handle', $criteria->set, $query->params));
     }
 }
    productViewedReport(GetSQLValueString($productid, "text"), $_SESSION["sess_userid"]);
    $USER_ID = $_SESSION["sess_userid"];
}
/* Items Bought By */
$resIB = DbHelper::execute("SELECT od.product_id,od.product_name,op.image_small,op.image_big\n            FROM " . $tableprefix . "order_details od\n                INNER JOIN " . $tableprefix . "product_options op ON od.product_option_id = op.product_option_id\n                INNER JOIN  " . $tableprefix . "products p ON p.product_id \t = op. \tproduct_id\n                    WHERE od.order_id IN (SELECT GROUP_CONCAT(DISTINCT d.order_id ORDER BY d.order_id DESC SEPARATOR ', ') FROM " . $tableprefix . "order_details d WHERE d.product_id = '" . mysql_real_escape_string($_GET['productid']) . "')\n                     AND p.deleted = 'N'   AND od.product_id != '" . $_GET['productid'] . "'  AND od.item_status IN(1, 3, 4) GROUP BY od.product_id LIMIT 0,12");
/*$resIB = DbHelper::execute("SELECT DISTINCT od.product_id,od.product_name,op.image_small,op.image_big
  FROM ".$tableprefix."order_details od
      LEFT JOIN ".$tableprefix."product_options op
          ON
          od.product_option_id = op.product_option_id LIMIT 12");*/
$IBArr = DbHelper::fetchAll($resIB);
/* Other Intrested Items Bought By */
//$resOI = DbHelper::execute("SELECT p.product_id,p.product_name,op.image_small,op.image_big FROM ".$tableprefix."products p LEFT JOIN ".$tableprefix."product_options op ON p.product_id = op.product_id WHERE p.vIntrest='Y' AND p.product_id != '".$_GET['productid']."' GROUP BY p.product_id LIMIT 0,12");
$sql_interest = "SELECT p.product_id,p.product_name,op.image_small,op.image_big FROM " . $tableprefix . "products p\n    LEFT JOIN " . $tableprefix . "product_options op ON p.product_id = op.product_id\n    INNER JOIN " . $tableprefix . "categories c ON c.category_id  = p.product_category\n        WHERE p.vIntrest='Y' AND p.product_id != '" . mysql_real_escape_string($_GET['productid']) . "'\n         AND p.deleted = 'N' AND c.vEnable='Y' GROUP BY p.product_id LIMIT 0,12";
$resOI = DbHelper::execute($sql_interest);
$OIArr = DbHelper::fetchAll($resOI);
/* display the active template */
$active_template = displayTemplate();
include "includes/htmltop.php";
/* Top File Name */
include_once "includes/" . $active_template[0];
$quantity = getWholesaleProductCount($prow["product_option_id"]);
// Check product is whole sale item or not
$eWholesaleItem = isWholesaleItem($productid);
//Check Selected Option Added to Wish List
$wishItemCount_Product = getWishItemsCount_Product($productid, $prow["product_option_id"]);
// Current Stock Available for a product
$currentStockAvailable = getCurrentStockAvailable($productid, $prow["product_option_id"]);
?>
<!--<script
	type="text/javascript"