'Datasources' => [
'default' => [
'className' => 'Cake\Database\Connection',
'driver' => 'Cake\Database\Driver\Mysql',
'persistent' => false,
'host' => 'localhost',
'login' => 'loginname',
'password' => 'password',
'database' => 'cake3_db',
'prefix' => false,
'encoding' => 'utf8',
],
/**
* The test connection is used during the test suite.
*/
'test' => [
'className' => 'Cake\Database\Connection',
'driver' => 'Cake\Database\Driver\Mysql',
'persistent' => false,
'host' => 'localhost',
'login' => 'my_app',
'password' => 'secret',
'database' => 'test_myapp',
'prefix' => false,
'encoding' => 'utf8',
],
],
after executing pr(), getting below msg
Cake\ORM\Query Object ( [_hasFields:protected] => [_useBufferedResults:protected] => 1 [_hydrate:protected] => 1 [_counter:protected] => [_eagerLoader:protected] => [_connection:protected] => Cake\Database\Connection Object ( [_config:protected] => Array ( [driver] => Cake\Database\Driver\Mysql [persistent] => [host] => localhost [login] => loginname [password] => password [database] => cake3_db [prefix] => [encoding] => utf8 [name] => default ) [_driver:protected] => Cake\Database\Driver\Mysql Object ( [_baseConfig:protected] => Array ( [persistent] => 1 [host] => localhost [login] => loginname [password] => [database] => cake [port] => 3306 [flags] => Array ( ) [encoding] => utf8 [timezone] => [init] => Array ( ) [dsn] => ) [_config:protected] => Array ( [driver] => Cake\Database\Driver\Mysql [persistent] => [host] => localhost [login] => loginname [password] => password [database] => cake3_db [prefix] => [encoding] => utf8 [name] => default [port] => 3306 [flags] => Array ( ) [timezone] => [init] => Array ( ) [dsn] => ) [_autoQuoting:protected] => [_startQuote:protected] => ` [_endQuote:protected] => ` [_schemaDialect:protected] => Cake\Database\Schema\MysqlSchema Object ( [_driver:protected] => Cake\Database\Driver\Mysql Object *RECURSION* ) [_connection:protected] => PDO Object ( ) ) [_transactionLevel:protected] => 0 [_transactionStarted:protected] => [_useSavePoints:protected] => [_logQueries:protected] => [_logger:protected] => ) [_type:protected] => select [_parts:protected] => Array ( [delete] => 1 [update] => Array ( ) [set] => Array ( ) [insert] => Array ( ) [values] => Array ( ) [select] => Array ( ) [distinct] => [modifier] => Array ( ) [from] => Array ( ) [join] => Array ( ) [where] => [group] => Array ( ) [having] => [order] => [limit] => [offset] => [union] => Array ( ) [epilog] => ) [_templates:protected] => Array ( [delete] => DELETE [update] => UPDATE %s [where] => WHERE %s [group] => GROUP BY %s [having] => HAVING %s [order] => %s [limit] => LIMIT %s [offset] => OFFSET %s [epilog] => %s ) [_transformedQuery:protected] => [_dirty:protected] => 1 [_resultDecorators:protected] => Array ( ) [_iterator:protected] => [_defaultTypes:protected] => Array ( [Posts.id] => integer [id] => integer [Posts.title] => string [title] => string [Posts.body] => text [body] => text [Posts.created] => datetime [created] => datetime [Posts.modified] => datetime [modified] => datetime ) [_valueBinder:protected] => [_functionsBuilder:protected] => [_repository:protected] => App\Model\Table\PostsTable Object ( [_table:protected] => posts [_alias:protected] => Posts [_connection:protected] => Cake\Database\Connection Object ( [_config:protected] => Array ( [driver] => Cake\Database\Driver\Mysql [persistent] => [host] => localhost [login] => loginname [password] => password [database] => cake3_db [prefix] => [encoding] => utf8 [name] => default ) [_driver:protected] => Cake\Database\Driver\Mysql Object ( [_baseConfig:protected] => Array ( [persistent] => 1 [host] => localhost [login] => loginname [password] => [database] => cake [port] => 3306 [flags] => Array ( ) [encoding] => utf8 [timezone] => [init] => Array ( ) [dsn] => ) [_config:protected] => Array ( [driver] => Cake\Database\Driver\Mysql [persistent] => [host] => localhost [login] => loginname [password] => password [database] => cake3_db [prefix] => [encoding] => utf8 [name] => default [port] => 3306 [flags] => Array ( ) [timezone] => [init] => Array ( ) [dsn] => ) [_autoQuoting:protected] => [_startQuote:protected] => ` [_endQuote:protected] => ` [_schemaDialect:protected] => Cake\Database\Schema\MysqlSchema Object ( [_driver:protected] => Cake\Database\Driver\Mysql Object *RECURSION* ) [_connection:protected] => PDO Object ( ) ) [_transactionLevel:protected] => 0 [_transactionStarted:protected] => [_useSavePoints:protected] => [_logQueries:protected] => [_logger:protected] => ) [_schema:protected] => Cake\Database\Schema\Table Object ( [_table:protected] => posts [_columns:protected] => Array ( [id] => Array ( [type] => integer [length] => 10 [unsigned] => 1 [null] => [default] => [comment] => [autoIncrement] => 1 [precision] => ) [title] => Array ( [type] => string [length] => 50 [null] => 1 [default] => [comment] => [precision] => [fixed] => ) [body] => Array ( [type] => text [length] => [null] => 1 [default] => [comment] => [precision] => ) [created] => Array ( [type] => datetime [length] => [null] => 1 [default] => [comment] => [precision] => ) [modified] => Array ( [type] => datetime [length] => [null] => 1 [default] => [comment] => [precision] => ) ) [_indexes:protected] => Array ( ) [_constraints:protected] => Array ( [primary] => Array ( [type] => primary [columns] => Array ( [0] => id ) [length] => Array ( ) ) ) [_options:protected] => Array ( ) ) [_primaryKey:protected] => [_displayField:protected] => [_associated:protected] => Cake\ORM\Associations Object ( [_items:protected] => Array ( ) ) [_eventManager:protected] => Cake\Event\EventManager Object ( [_listeners:protected] => Array ( ) [_isGlobal:protected] => ) [_behaviors:protected] => Cake\ORM\BehaviorRegistry Object ( [_table:protected] => App\Model\Table\PostsTable Object *RECURSION* [_eventManager:protected] => Cake\Event\EventManager Object ( [_listeners:protected] => Array ( ) [_isGlobal:protected] => ) [_methodMap:protected] => Array ( ) [_finderMap:protected] => Array ( ) [_loaded:protected] => Array ( ) ) [_entityClass:protected] => [_validators:protected] => Array ( ) ) [_results:protected] => [_mapReduce:protected] => Array ( ) [_formatters:protected] => Array ( ) [_cache:protected] => [_options:protected] => Array ( ) )
Please help..
Thanks
On Mon, Mar 3, 2014 at 11:47 PM, José Lorenzo <jose.zap@gmail.com> wrote:
You need to update your app template, specifically your app.php file as the arguments for configuring a database connection recently changed:--
On Monday, March 3, 2014 4:49:53 PM UTC+1, Bayezid Alam wrote:Dears,DB Connection in Cake3Located at /var/www/cake3/App/Config/app.php/*** Connection information used by the ORM to connect* to your application's datastores.*/'Datasources' => ['default' => ['className' => 'Cake\\Database\\Driver\\Mysql','persistent' => false,'host' => 'localhost','login' => 'loginName','password' => 'PassWord','database' => 'DatabaseName','prefix' => false,'encoding' => 'utf8',],/*** The test connection is used during the test suite.*/'test' => ['className' => 'Cake\\Database\\Driver\\Mysql','persistent' => false,'host' => 'localhost','login' => 'my_app','password' => 'secret','database' => 'test_myapp','prefix' => false,'encoding' => 'utf8',],],My Controller located at /var/www/cake3/App/Controller/PostsController.php<?php/** To change this template, choose Tools | Templates* and open the template in the editor.*/namespace App\Controller;use Cake\ORM\TableRegistry;class PostsController extends AppController{public $helpers = array('Html', 'Form');public function index(){$posts = TableRegistry::get('Posts');$posts = $posts->find();$this->set('posts', $posts);}}?>My Table located at /var/www/cake3/App/Model/Table/PostsTable.php<?php/** To change this template, choose Tools | Templates* and open the template in the editor.*/namespace App\Model\Table;use Cake\ORM\Table;class PostsTable extends Table{public function initialize(array $config){$this->table('posts');}}?>View located at /var/www/cake3/App/Template/Posts/index.ctp<h1>Blog posts</h1><table><tr><th>Id</th><th>Title</th><th>Created</th></tr><!-- Here is where we loop through our $posts array, printing out post info --><?php foreach ($posts as $post): ?><tr><td><?php echo $post['Post']['id']; ?></td><td><?php echo $this->Html->link($post['Post']['title'],array('controller' => 'posts', 'action' => 'view', $post['Post']['id'])); ?></td><td><?php echo $post['Post']['created']; ?></td></tr><?php endforeach; ?><?php unset($post); ?></table>It's showing only Header names, not bringing any data from Database. i Have three more records on database.Please help me, am i missing any thing or not?
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment