PHP code example of dzlzh / leancloud

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

    

dzlzh / leancloud example snippets




use \leancloud\leancloud;
$leancloud = new leancloud($config);

$data = array(
    'name' => 'xiaoming',
    'age'  => 24,
    'sex'  => 'man',
);
$id = $leancloud->build('test')->set($data)->save();
var_dump($id);

$newData = array(
    'age' => 30,
);

$leancloud->build('test', $id)->set($newData)->save();

$leancloud->build('test', $id)->destroy();

$newData = $leancloud->build('test', $id)->get();
var_dump($newData->get('name'));
var_dump($newData->get('age'));
var_dump($newData->get('sex'));

$sql = 'SELECT * FROM test WHERE age=30';
$data = $leancloud->query($sql);
var_dump($data);
foreach ($data as $value) {
    var_dump($value->getObjectId());
    var_dump($value->get('name'));
    var_dump($value->get('age'));
    var_dump($value->get('sex'));
    var_dump($value->getCreatedAt());
    var_dump($value->getUpdatedAt());
}