/** * Augment the provided Select object with all the EAV attribute values from this * definition. * * @param Select $select * @return Select * @throws Select */ public function augmentSelect(Select $select) { $db = $this->table->getAdapter(); $id = current($this->table->getPrimaryKey()); $rootTableAlias = $select->quoteWithAlias($this->table->getTableName(), $id); foreach ($this->getAttributes() as $attribute) { $alias = 'eav_' . $attribute['attribute_id']; $table = $this->table->getTableName() . $this->valueTablePrefix . $attribute['backend_type']; $select->joinLeft([$alias => $table], $db->quoteInto("{$alias}.{$id} = {$rootTableAlias} AND {$alias}.attribute_id = ?", $attribute['attribute_id']), [$alias => 'value']); } return $select; }
/** * Assemble the WHERE clause for the update method using the primary key * column's from the associated table. * * @return string */ private function assembleUpdateWhereClause() { $pkey = $this->table->getPrimaryKey(); $db = $this->table->getAdapter(); $where = array(); foreach ($pkey as $column) { $quotedColumn = $db->quoteIdentifier($column); $where[] = $db->quoteInto("{$quotedColumn} = ?", $this->data[$column]); } return implode(' AND ', $where); }
/** * A shortcut for linkByQueryString() that uses Table object get the model * and query string param name. * * @param Table $table * @return RowEditor * @throws Exception */ public function linkTableByQueryString(Table $table) { $primaryKey = $table->getPrimaryKey(); if (1 !== count($primaryKey)) { throw new Exception('Can only use linkTableByQueryString() when a single primary key column is present.'); } return $this->linkByQueryString($table->getTableName(), current($primaryKey)); }