Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document specific query builder functions #2318

Merged
merged 2 commits into from
Oct 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions docs/en/migrations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1675,6 +1675,34 @@ be easy to work with as it resembles very closely plain SQL. Accesing the query
}
}

Alternatively, the following methods are available to enhance code organization and improve clarity:

* ``getSelectBuilder()``: Returns a SelectQuery object for building SELECT statements.
* ``getInsertBuilder()``: Returns an InsertQuery object for building INSERT statements.
* ``getUpdateBuilder()``: Returns an UpdateQuery object for building UPDATE statements.
* ``getDeleteBuilder()``: Returns a DeleteQuery object for building DELETE statements.


.. code-block:: php

<?php

use Phinx\Migration\AbstractMigration;

class MyNewMigration extends AbstractMigration
{
/**
* Migrate Up.
*/
public function up()
{
$builder = $this->getSelectBuilder();
$statement = $builder->select('*')->from('users')->execute();
var_dump($statement->fetchAll());
}
}


Selecting Fields
~~~~~~~~~~~~~~~~

Expand Down
Loading