public function __construct(Mapper $mapper, $class) { if (!$this->engine) { throw new \UnexpectedValueException(); } $this->mapper = $mapper; if ($class instanceof Meta) { $this->meta = $class; } else { $this->meta = $mapper->getMeta($class); } }
protected function buildField($id, $info, $default) { $current = "`{$info['name']}` "; $colType = null; if (isset($info['type'])) { $handler = $this->mapper->determineTypeHandler($info['type']['id']); if ($handler) { $new = $handler->createColumnType($this->engine, $info); if ($new) { $colType = $new; } } if (!$colType) { $colType = $info['type']['id']; } } $current .= $colType ?: $default; return $current; }
protected function executeDelete(Meta $meta, Query\Criteria $criteria) { $table = $criteria->table ?: $meta->table; list($whereClause, $whereParams, $whereProps) = $criteria->buildClause($meta); if (!$whereClause) { throw new \UnexpectedValueException("Empty where clause"); } if ($whereProps) { $whereParams = $this->mapper->formatParams($meta, $whereProps, $whereParams); } $t = ($meta->schema ? "`{$meta->schema}`." : null) . "`{$table}`"; $sql = "DELETE FROM {$t} WHERE {$whereClause}"; $stmt = $this->getConnector()->prepare($sql)->execute($whereParams); }