diff --git a/src/Doctrine/CreateControllerCommand.php b/src/Doctrine/CreateControllerCommand.php index aa1dd42..d31acb1 100644 --- a/src/Doctrine/CreateControllerCommand.php +++ b/src/Doctrine/CreateControllerCommand.php @@ -195,8 +195,7 @@ public function execute() '[plural]', '[pluralText]', '[singular]', - '[singularText]', - '[table]' + '[singularText]' ); $replace = array( @@ -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); diff --git a/src/Doctrine/Templates/Controller.txt b/src/Doctrine/Templates/Controller.txt index 3671c58..7265cd3 100644 --- a/src/Doctrine/Templates/Controller.txt +++ b/src/Doctrine/Templates/Controller.txt @@ -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'); diff --git a/src/Doctrine/Templates/Library.txt b/src/Doctrine/Templates/Library.txt index d515c96..0c17e62 100644 --- a/src/Doctrine/Templates/Library.txt +++ b/src/Doctrine/Templates/Library.txt @@ -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(); diff --git a/src/Wildfire/CreateControllerCommand.php b/src/Wildfire/CreateControllerCommand.php index b6cf8ff..fe85ac2 100644 --- a/src/Wildfire/CreateControllerCommand.php +++ b/src/Wildfire/CreateControllerCommand.php @@ -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') );