PHP code example of stratedge / wye

1. Go to this page and download the library: Download stratedge/wye library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

stratedge / wye example snippets




use Stratedge\Wye\Wye;

//In test setup
//-------------

//Reset the Wye to its clean state
Wye::reset()

//Create a Wye PDO object
$pdo = Wye::makePDO();

//Inject PDO into database layer
Database::setConnection($pdo);

//In test
//-------

//Create a Result object
$result = Wye::makeResult();

//Add a row or two to return
$result->addRow(['type' => 'Pumper', 'apparatus' => 'Engine 1']);

//Attach Result to Wye to be served when a query is executed
$result->attach();

//Run code to test
$class_to_test->doSomething();

//Inspect execution
$stmt = Wye::getStatementAtIndex(0);
$this->assertStringStartsWith('SELECT', $stmt->getStatement());
$this->assertCount(2, count($stmt->getBindings());
$this->assertSame('id', $stmt->getBindings()->first()->getParameter());
$this->assertSame(1, Wye::getNumQueries());
//and more!