PHP code example of jaxonrailey / vane

1. Go to this page and download the library: Download jaxonrailey/vane 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/ */

    

jaxonrailey / vane example snippets


use JaxonRailey\Vane;

$vane = new Vane();

$planets = [
    [
        'name'        => 'mercury',
        'temperature' => 440,
        'distance'    => 57910000,
        'satellites'  => 0,
        'atmosphere'  => [],
        'discoverer'  => [
            'firstname'   => 'Giovanni',
            'lastname'    => 'Schiaparelli',
            'nationality' => 'Italian'
        ]
    ],
    [
        'name'        => 'venus',
        'temperature' => 737,
        'distance'    => 108200000,
        'satellites'  => 0,
        'atmosphere'  => ['nitrogen', 'water', 'argon'],
        'discoverer'  => [
            'firstname'   => 'Giovanni',
            'lastname'    => 'Cassini',
            'nationality' => 'Italian'
        ]
    ],
    [
        'name'        => 'earth',
        'temperature' => 15,
        'distance'    => 149600000,
        'satellites'  => 1,
        'atmosphere'  => ['nitrogen', 'oxygen', 'water', 'neon']
    ],
    [
        'name'        => 'mars',
        'temperature' => -63,
        'distance'    => 227940000,
        'satellites'  => 2,
        'atmosphere'  => ['nitrogen', 'argon', 'oxygen', 'water'],
        'discoverer'  => [
            'firstname'   => 'Edward',
            'lastname'    => 'Barnard',
            'nationality' => 'American'
        ]
    ],
    [
        'name'        => 'jupiter',
        'temperature' => -108,
        'distance'    => 778330000,
        'satellites'  => 79,
        'atmosphere'  => ['hydrogen', 'helium', 'methane'],
        'discoverer'  => [
            'firstname'   => 'Galileo',
            'lastname'    => 'Galilei',
            'nationality' => 'Italian'
        ]
    ],
    [
        'name'        => 'saturn',
        'temperature' => -139,
        'distance'    => 1429400000,
        'satellites'  => 82,
        'atmosphere'  => ['hydrogen', 'helium', 'methane'],
        'discoverer'  => [
            'firstname'   => 'Galileo',
            'lastname'    => 'Galilei',
            'nationality' => 'Italian'
        ]
    ],
    [
        'name'        => 'uranus',
        'temperature' => -197,
        'distance'    => 2870990000,
        'satellites'  => 27,
        'atmosphere'  => ['hydrogen', 'helium', 'methane', 'water'],
        'discoverer'  => [
            'firstname'   => 'William',
            'lastname'    => 'Herschel',
            'nationality' => 'German-British'
        ]
    ],
    [
        'name'        => 'neptune',
        'temperature' => -201,
        'distance'    => 4504300000,
        'satellites'  => 14,
        'atmosphere'  => ['hydrogen', 'helium', 'methane', 'water'],
        'discoverer'  => [
            'firstname'   => 'Urbain',
            'lastname'    => 'Le Verrier',
            'nationality' => 'French'
        ]
    ]
];

$vane->select('*');
$vane->from('planet');
$rows = $vane->rows();

$vane->from('planet');
$vane->save($planets);

$vane->from('planet');
$vane->where('temperature', '>', 0);
$vane->save(['star' => 'Sun']);

$vane->from('planet');
$vane->where('temperature', '>', 0);
$vane->delete();

$vane->from('planet');
$vane->truncate();

$vane->select('*');
$vane->from('planet');
$vane->contains('atmosphere', 'methane');
$rows = $vane->rows();

$vane->select('*');
$vane->from('planet');
$vane->contains('atmosphere', 'methane', false);
$rows = $vane->rows();

$vane->select('*');
$vane->from('planet');
$vane->exists('discoverer');
$rows = $vane->rows();

$vane->select('*');
$vane->from('planet');
$vane->exists('discoverer', false);
$rows = $vane->rows();

$vane->select('*');
$vane->from('planet');
$vane->counter('atmosphere', '>', 3);
$rows = $vane->rows();

$vane->select('*');
$vane->from('planet');
$row = $vane->id('<id-of-element>');

$vane->select('name', 'distance');
$vane->from('planet');
$rows = $vane->rows();

$vane->select('discoverer.firstname');
$vane->from('planet');
$vane->where('discoverer.nationality', '=', 'Italian');
$rows = $vane->rows();

$vane->where('name', 'mercury');

$vane->where('name', '=', 'mercury');

$vane->counter('atmosphere', 3);

$vane->counter('atmosphere', '=', 3);