PHP code example of emeka / candy

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

    

emeka / candy example snippets


$users = User::all();
echo $users;

$users = User::find($id);
echo $users;

$value = "username"
$field = "user's table"

echo $user = User::where($value, $field)

$user = new User;
$user->email     = "[email protected]";
$user->username  = "john";
$user->password  = "password";
//without the ID property the Save method will insert a new record in to  the database 
$user::save();

$user = new User;
$user->id        = 1;
$user->email     = "[email protected]";
$user->username  = "new_john";
$user->password  = "new_password";
//with the ID property the Save method will update the USERS table where ID = 1. 
$user::save();

$user = User::destroy($id):
$user returns a boolean