PHP code example of davewid / peyote

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

    

davewid / peyote example snippets

 sql
SELECT * FROM user WHERE user_id = ?
 php
$query = new \Peyote\Select('user');
$query->where('user_id', '=', 1);

echo $query->compile();
// output: SELECT * FROM user WHERE user_id = ?
 php
$data = array(
	'email' => "[email protected]",
	'password' => "youllneverguess"
);

$query = new \Peyote\Insert('user');
$query->columns(array_keys($data))->values(array_values($data));

echo $query->compile();
// output: INSERT INTO user (email, password) VALUES (?, ?)
 php
$data = array(
	'password' => "iguesssomebodyguessed"
);

$query = new \Peyote\Update('user');
$query->set($data)->where('user_id', '=', 1);

echo $query->compile();
// output: UPDATE user SET password = ? WHERE user_id = ?
 php
$query = new \Peyote\Delete('user');
$query->where('user_id', '=', 1);

echo $query->compile();
// output: DELETE FROM user WHERE user_id = ?
 php
$query = new \Peyote\Create('user');
$query->setColumns(array(
  // Add Columns here....
));

echo $query->compile();
// output: CREATE TABLE user ( {columns here...} ) ENGINE=MyISAM DEFAULT CHARSET=utf8
 php
$query = new \Peyote\Alter('user');

// As string...
$query->addColumn('activated TINYINT NOT NULL');

// As Column...
$column = new \Peyote\Column('activated', 'TINYINT', array('is_null' => false));
$query->addColumn($column);

echo $query->compile();
// Output: 'ALTER TABLE user ADD activated TINYINT NOT NULL';
 php
$query = new \Peyote\Drop('user');
echo $query->compile();
// Output: DROP TABLE user