MySQL commands conversion to Yii create - php

Firstly I'm not an expert in Yii, MySQL or PHP.
I'm designing my database tables with MySQL Workbench, I'm not able to avoid that the Workbench creating more than a primary index so CRUD doesn't work properly. Now I'm trying to convert the MySQL code to create the tables in the create tool of Yii syntax. Are there any programs or extensions to do this automatically?

http://www.yiiframework.com/extension/database-command/
You can use that to create a dump of the database as a Yii migration (that's a bunch of PHP code with the MySQL commands to install your database). Migrations can then be imported using yiic migrate, assuming they're in the migrations folder, or by also providing a migration path (default location for dumps from that extension is the runtime folder).
Next you'll probably want to create a new migrations for all your database changes. See the database migrations guide for more info on how to do that.

Related

Work in teams using MySql and xampp localhost - can't update the database

Me and some friends are working on a PHP page and we need a MySql database(we need to present the xampp localhost version). Since we will all make edits there we need a way to somehow update our local database with others work when they do it.
I tried to export the database from them and import in my phpmyadmin but for this I have to delete my old database. Isn't there a method to just update it? I mean what can they make to send me a file with an update and how can I import just an update?
I tried to search the answer for hours but couldn't find something specific.
I think the main problem is to synchronize database table changes, not data.
You must read about migrations and don't interact database directly from PHPMyAdmin.
Phinx is the most popular tool in PHP about migrations.
https://phinx.org/

Laravel, migrate existing table from local phpmyadmin to server

Im new to laravel, someone asked me to modify in his project, these modifications need to have new tables, I created tables directly on phpmyadmin, these tables include countries and regions tables which have huge rows, I wanted to push the project to the server but don't have access to the database so must using migrate, my questions are:
how can I migrate the tables I created in phpmyadmin? I didnt create tables using the command artisan migrate.
how can I push countries and regions tables contents?
thank you in advance
Firstly familarise yourself with the documentation on Laravel Migrations (https://laravel.com/docs/6.x/migrations). The documenation is excellent!
If you want to replicate the structure of the table you have already created, I would start by getting the table schema from phpmyadmin and then simply walking through it line by line and finding the appropriate methods in the documentation.
Once you have matched the table structure, it then just a case of taking a database dump of your existing table and importing it.
To update the production server database you still can use migrations, even if you created tables manually on local environment.
Please read the docs for more info.
Run the command: php artisan make:migration table-name in local environment, and write required columns in created file.
After that, you can upload this file on the server and just run: php artisan migrate this will create tables on the prod database.
To automatically insert data after migrations you can use seeding: https://laravel.com/docs/5.7/seeding
This is not a correct approach, If you are using Laravel and manually uploading the data.
The better solution is to write the migrations and seeder.
You can print db result in an array and paste everything in your Seeder file, Check the syntax on Laravel website

Migrations Table Empty - Can't run php artisan migrate

So, I've copied a database off a server that I'm working on and I've just started working on it. However for some reason the migrations table is empty so when I try to run php artisan migrate it can't because it doesn't know that all the tables are already created. Is there a quick way of fixing this rather then adding in the name of every migration to the table manually as there are a lot of migrations in this project?
Thanks.
You can work around it the following way:
Create another empty database.
Switch your application to use the new database.
Run php artisan migrate
Copy migrations table from new database to the old one
Switch your application to use the old database again.
You could also delete existing migration files (bad idea) or move them to some other folder so that migrate command doesn't see them.
You could also fill the table yourself, but that seems pretty time consuming.
Why is that table empty in the first place? Is it empty on your server as well?

How to run any existing CodeIgniter project on Xampp?

I am new to CodeIgniter. Kindly tell me how to run any existing project developed using CodeIgniter on Xampp. It has no database. How can I create database for this project?
how to run: open index file in browser or cli.
how to create database- well if you don't have dump, then you are out of luck and only option is to investigate queries and try to replicate tables.

Symfony CMF Sandbox mysql

I'm trying to install Symfony CMF with mysql database.
Can somebody tell me step after step how to do it ?
I've already downloaded project and i'm trying to migrate to mysql from sqlite but i don't know how.
There is a tutorial in the doc: http://symfony.com/doc/master/cmf/cookbook/editions/cmf_sandbox.html . look into the file app/config/phpcr.yml that you create in the configuration step.
The database is configured in app/config/parameters.yml. you will have to modify that file to use MySQL. you will then also have to reinitialize the database etc. note if you want to migrate the data from the sqlite install you should export your data to xml before you switch to mysql using app/console doctrine:phpcr:workspace:export /cms

Categories