Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarotero committed Sep 8, 2015
1 parent 6ca2755 commit 1470292
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 16 deletions.
2 changes: 2 additions & 0 deletions src/BaseRow.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

/**
* Base class used by Row and RowCollection
*
* @property mixed $id
*/
abstract class BaseRow implements RowInterface
{
Expand Down
2 changes: 1 addition & 1 deletion src/EntityFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function get($name)

return new $class($name, $this->db, $queryFactory, $fieldFactory);
}
} catch (Exception $exception) {
} catch (\Exception $exception) {
throw new SimpleCrudException("Error getting the '{$name}' entity", 0, $exception);
}

Expand Down
2 changes: 1 addition & 1 deletion src/FieldFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function get($name, $type = null)
$class = $this->cachedTypes[$type] = $this->defaultType;

return new $class();
} catch (Exception $exception) {
} catch (\Exception $exception) {
throw new SimpleCrudException("Error getting the '{$type}' field", 0, $exception);
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/Queries/LimitTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

/**
* Common function to manage LIMIT clause
*
* @property \SimpleCrud\Entity $entity
*/
trait LimitTrait
{
Expand Down
12 changes: 6 additions & 6 deletions src/Queries/Mysql/Select.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public function __toString()
$query .= ' '.static::buildFields($this->entity->name, array_keys($this->entity->fields));

foreach ($this->leftJoin as $join) {
$query .= ', '.static::buildFields($join['entity']->name, array_keys($join['entity']->fields), $join['entity']->name);
$query .= ', '.static::buildFields($join['entity']->name, array_keys($join['entity']->fields), true);
}

$query .= $this->fieldsToString();
Expand Down Expand Up @@ -191,19 +191,19 @@ public function __toString()
/**
* Generates the fields/tables part of a SELECT query
*
* @param string $table
* @param array $fields
* @param string|null $rename
* @param string $table
* @param array $fields
* @param bool $rename
*
* @return string
*/
protected static function buildFields($table, array $fields, $rename = null)
protected static function buildFields($table, array $fields, $rename = false)
{
$query = [];

foreach ($fields as $field) {
if ($rename) {
$query[] = "`{$table}`.`{$field}` as `{$rename}.{$field}`";
$query[] = "`{$table}`.`{$field}` as `{$table}.{$field}`";
} else {
$query[] = "`{$table}`.`{$field}`";
}
Expand Down
2 changes: 2 additions & 0 deletions src/Queries/Sqlite/CompiledOptionsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

/**
* Manages a database select count query in Mysql databases
*
* @property \SimpleCrud\Entity $entity
*/
trait CompiledOptionsTrait
{
Expand Down
2 changes: 2 additions & 0 deletions src/Queries/WhereExtendedTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

/**
* Common function to manage WHERE clause
*
* @property \SimpleCrud\Entity $entity
*/
trait WhereExtendedTrait
{
Expand Down
2 changes: 2 additions & 0 deletions src/Queries/WhereTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

/**
* Common function to manage WHERE clause
*
* @property \SimpleCrud\Entity $entity
*/
trait WhereTrait
{
Expand Down
2 changes: 1 addition & 1 deletion src/QueryFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function get($name)
return new $class($this->entity);
}
}
} catch (Exception $exception) {
} catch (\Exception $exception) {
throw new SimpleCrudException("Error getting the '{$name}' query", 0, $exception);
}

Expand Down
2 changes: 0 additions & 2 deletions src/Row.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

/**
* Stores the data of an entity row
*
* @property mixed $id
*/
class Row extends BaseRow implements JsonSerializable
{
Expand Down
6 changes: 2 additions & 4 deletions src/RowCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

/**
* Stores a collection of rows
*
* @property array $id
*/
class RowCollection extends BaseRow implements ArrayAccess, Iterator, Countable
{
Expand Down Expand Up @@ -54,7 +52,7 @@ public function __get($name)
$collection[] = $r;
}
} else {
$collection = $r;
$collection = $row;
}
}

Expand All @@ -74,7 +72,7 @@ public function __get($name)

//Returns values
if ($first->has($name)) {
return $this->get($name, isset($arguments[0]) ? $arguments[0] : null);
return $this->get($name);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/SimpleCrud.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class SimpleCrud
{
protected $connection;
protected $inTransaction = false;
protected $factory;
protected $entityFactory;
protected $entities = [];
protected $attributes = [];

Expand Down

0 comments on commit 1470292

Please sign in to comment.