execute() публичный метод

Execute a query and return a Database\Result object
public execute ( string $strQuery ) : Result | object
$strQuery string The query string
Результат Contao\Database\Result | object The Database\Result object
Пример #1
0
 /**
  * Multiple-fields (e.g. select or checkbox) with numberic keys are stored as CSV to improve filters.
  */
 private function convertSerializedValues()
 {
     $t = Attribute::getTable();
     $fields = array();
     $attributes = Attribute::findBy(array("{$t}.multiple='1' AND {$t}.optionsSource='foreignKey'"), null);
     if (null !== $attributes) {
         /** @var Attribute $attribute */
         foreach ($attributes as $attribute) {
             if ($attribute instanceof IsotopeAttributeWithOptions) {
                 $fields[] = $attribute->field_name;
             }
         }
     }
     if (!empty($fields)) {
         /** @var \Database\Result|object $products */
         $products = $this->db->execute("\n                SELECT id, " . implode(', ', $fields) . "\n                FROM tl_iso_product\n                WHERE " . implode(" IS NOT NULL OR ", $fields) . " IS NOT NULL\n            ");
         while ($products->next()) {
             $set = array();
             foreach ($fields as $field) {
                 $value = deserialize($products->{$field});
                 if (!empty($value) && is_array($value)) {
                     $set[$field] = implode(',', $value);
                 }
             }
             if (!empty($set)) {
                 $this->db->prepare("UPDATE tl_iso_product %s WHERE id=?")->set($set)->execute($products->id);
             }
         }
     }
 }
Пример #2
0
 public function run($blnInstalled)
 {
     $this->db = \Database::getInstance();
     if ($blnInstalled) {
         $collections = $this->db->execute("SELECT uniqid, COUNT(id) AS total\n                FROM tl_iso_product_collection\n                WHERE uniqid IS NOT NULL\n                GROUP BY uniqid\n                HAVING total>1");
         while ($collections->next()) {
             $this->db->prepare("UPDATE tl_iso_product_collection SET uniqid=NULL WHERE uniqid=?")->execute($collections->uniqid);
         }
     }
 }