使用CakePHP如何从数据库导出数据。 不包括架构

In my CakePHP App, I have exported my database schema, however now I just need the data that I will use to pre-populate for the user.

Will not work as it generates only the schema:

cake schema generate

Looking for a solution that will generate an Insert or Update of current data in the db.

Update:

This is for an installer that I am writing. When a user completes the installation it should populate the db with data required for the app.

NOTE: The OP is not asking how to get data from the database command line per se. He wants to create an installer that will populate a database when the user runs the installation. For example, when you install WordPress, you are not going to run mysqldump, right? The application takes care of it. This is a similar situation.

The easiest way to do this is to use the models that come with the application.

Check to see if the system is installed, if not run the following:

  1. open the installer asking for the DB credentials in a form
  2. use the credentials to create the database
  3. if the database cannot be created, explain that they must create the database manually
  4. save the credentials to the correct location in the database.php config
  5. create the schema from within the controller
  6. once the schema is built, load all of the pre-set data from the model

Take advantage of the install controller / db models within cake to do the lifting. So for example, if you want to pre-load some configuration settings:

$config['Config']['setting_1'] = 'foo';
$config['Config']['setting_2'] = 'bar';

$this->loadModel('Config');
$this->Config->create();
$this->Config->save($config);

Hope that helps.

Use MySQL to do this:

mysqldump -u <username> -p <databasename>

Replace and with your username and database names.