Skip to content

Commit

Permalink
Fixed errors regarding in Doctrine
Browse files Browse the repository at this point in the history
  • Loading branch information
rougin committed Jun 22, 2015
1 parent cda8f78 commit d9d029d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
6 changes: 2 additions & 4 deletions src/Doctrine/CreateControllerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,7 @@ public function execute()
'[plural]',
'[pluralText]',
'[singular]',
'[singularText]',
'[table]'
'[singularText]'
);

$replace = array(
Expand All @@ -211,8 +210,7 @@ public function execute()
Tools::stripTableSchema($plural),
strtolower($plural),
Tools::stripTableSchema(singular($name)),
strtolower(humanize($name)),
$this->_input->getArgument('name')
strtolower(humanize(singular($name)))
);

$controller = str_replace($search, $replace, $controller);
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/Templates/Controller.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class [controller] extends CI_Controller {

$config['base_url'] = base_url('[plural]');
$config['suffix'] = '&keyword=' . $delimiters['keyword'];
$config['total_rows'] = $this->doctrine->get_all('[table]', $delimiters)->total_rows();
$config['total_rows'] = $this->doctrine->get_all('[singular]', $delimiters)->total_rows();

$delimiters['page'] = $this->input->get($this->config->item('query_string_segment'));
$delimiters['per_page'] = $this->config->item('per_page');
Expand Down
10 changes: 5 additions & 5 deletions src/Doctrine/Templates/Library.txt
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,15 @@ class Doctrine {

if (isset($delimiters['per_page']) && $delimiters['per_page'] != NULL)
{
$page = $delimiters['page'];
$page = $delimiters['per_page'] * $delimiters['page'] - $delimiters['per_page'];

if ($page != NULL)
if ($page == NULL || $page < 0)
{
$page = $delimiters['per_page'] * $page - $delimiters['per_page'];
$page = 0;
}

$this->_query_builder->setFirstResult($delimiters['page']);
$this->_query_builder->setMaxResults($page);
$this->_query_builder->setFirstResult($page);
$this->_query_builder->setMaxResults($delimiters['per_page']);
}

$this->_query = $this->_query_builder->getQuery();
Expand Down
2 changes: 1 addition & 1 deletion src/Wildfire/CreateControllerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public function execute()
Tools::stripTableSchema($plural),
strtolower($plural),
Tools::stripTableSchema(singular($name)),
strtolower(humanize($name)),
strtolower(humanize(singular($name))),
$this->_input->getArgument('name')
);

Expand Down

0 comments on commit d9d029d

Please sign in to comment.