kandi background

phinx | PHP Database Migrations for Everyone | Data Migration library

Download this library from

kandi X-RAY | phinx Summary

phinx is a PHP library typically used in Migration, Data Migration, PostgresSQL applications. phinx has no bugs, it has no vulnerabilities, it has a Permissive License and it has medium support. You can download it from GitHub.
PHP Database Migrations for Everyone

kandi-support Support

  • phinx has a medium active ecosystem.
  • It has 4266 star(s) with 901 fork(s). There are 144 watchers for this library.
  • There were 1 major release(s) in the last 6 months.
  • There are 130 open issues and 848 have been closed. On average issues are closed in 99 days. There are 4 open pull requests and 0 closed requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of phinx is 0.12.10

quality kandi Quality

  • phinx has 0 bugs and 0 code smells.

securitySecurity

  • phinx has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • phinx code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.

license License

  • phinx is licensed under the MIT License. This license is Permissive.
  • Permissive licenses have the least restrictions, and you can use them in most projects.

buildReuse

  • phinx releases are available to install and integrate.
  • Installation instructions, examples and code snippets are available.
  • phinx saves you 4931 person hours of effort in developing the same functionality from scratch.
  • It has 10621 lines of code, 1009 functions and 78 files.
  • It has high code complexity. Code complexity directly impacts maintainability of the code.
Top functions reviewed by kandi - BETA

kandi has reviewed phinx and discovered the below as its top functions. This is intended to give you an instant insight into phinx implemented functionality, and help decide if they suit your requirements.

  • Print the migration status .
  • Returns the instructions to alter a column .
  • Resolve conflicts .
  • Parse a default value .
  • Set the data domain .
  • Get PHinx type
  • Load a configuration file .
  • Parse dsn from dsn
  • Get inverted commands .
  • Resolve migration path .

phinx Key Features

Write database migrations using database agnostic PHP code.

Migrate up and down.

Migrate on deployment.

Seed data after database creation.

Get going in less than 5 minutes.

Stop worrying about the state of your database.

Take advantage of SCM features such as branching.

Integrate with any app.

phinx Examples and Code Snippets

  • Composer
  • As a Phar
  • Fetch data for a select query in yii migrations
  • MySQL: How do you query on a compound-primary-key? Specifically, a NOT IN query?
  • Phinx migration error, "Could not find class" but looking in the correct file?
  • How i can getDatabaseName in Phinx?

Composer

curl -sS https://getcomposer.org/installer | php

Community Discussions

Trending Discussions on phinx
  • Fetch data for a select query in yii migrations
  • MySQL: How do you query on a compound-primary-key? Specifically, a NOT IN query?
  • Cakephp 4 Windows Installation Issues
  • Phinx migration error, "Could not find class" but looking in the correct file?
  • How i can getDatabaseName in Phinx?
Trending Discussions on phinx

QUESTION

Fetch data for a select query in yii migrations

Asked 2021-May-12 at 14:01

I am creating a parent child table using yii migration where there is a foreign key on the child table. I tried using execute but that did not help me fetching the data needed. Is there a way I can query the parent table and insert the parent id on the child table as a foreign key? Something like fetch()/fetchAll() that is used inside phinx migrations.

    $this->batchInsert('{{%parent_table}}',
                ['name'],
                [
                    ['P1'],
                    ['P2'],
                    ['P3'],
                    ['P4']
                ]
            );
    $a = $this->execute("select * from parent_table where name = 'P1'");
    // get the data from the table that will get me the id from the above query.

    $this->batchInsert('{{%child_table}}',
                [['name'],['parent_id']],
                [
                    ['C1','<parent id>'],
                    ['C2','<parent id>'],
                    .
                    .
                    .
                ]
            );

ANSWER

Answered 2021-May-11 at 22:38

You need to use

$res = Yii::$app->db->createCommand("select * from parent_table where name = 'P1'")->queryAll();

The $this->execute() is used to execute sql statements like update or delete instead

Edit

Better use $this->db instead of Yii::$app->db to make sure you are running on the same db, as mentioned in the comments

Source https://stackoverflow.com/questions/67490844

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

Vulnerabilities

No vulnerabilities reported

Install phinx

See version and branch overview for branch and PHP compatibility.

Support

Phinx natively supports the following database adapters:.

Build your Application

Share this kandi XRay Report