PHP code example of intelligenia / lulo

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

    

intelligenia / lulo example snippets


function get_db_settings(){
    $db_settings = [
        "server" => "<DB SERVER>",
        "user" => "<DB USER>",
        "password" => "<DB PASSWORD>",
        "database" => "<DATABASE>"
    ];
    return $db_settings;
}

/**
 * Example user class for a social-network-like system.
 * @author Diego J. Romero López at intelligenia.
 * */
class User extends \lulo\models\LuloModel{
	
	/** Model table */
	const TABLE_NAME = "user";
	
	/** Class name*/
	const CLASS_NAME = __CLASS__;
	
	/**
	 * Metainformation of the class
	 * */
	public static $META = [
		// Description of the model
		"model_description" => "Test user",
		// Verbose name
		"verbose_name" => "test user",
		// Verbose name (plural)
		"verbose_name_plural" => "test users",
		// Gender of the verbose name
		"gender" => "m",
		// Order in lists (["field1"=>"ASC|DESC", "field2"=>"ASC|DESC", ...])
		"order" => ["username"=>"ASC"]
	];
	
	/**
	 * Model attributes
	 * */
	protected static $ATTRIBUTES = [
		// Primary key
		"stack"=>["type"=>"string", "default"=>TEST_STACK, "verbose_name"=>"User dependant stack", "auto"=>true],
		"id" => ["type"=>"int", "verbose_name"=>"Identificador único del usuario", "auto"=>true],
		
        	// Proper user fields
		"first_name" => ["type"=>"string", "verbose_name"=>"Name", "access"=>"rw"],
		"last_name" => ["type"=>"string", "verbose_name"=>"Family name"],
		"email" => ["type"=>"string", "subtype"=>"email", "verbose_name"=>"E-Mail"],
		"phone" => ["type"=>"string", "subtype"=>"phone", "verbose_name"=>"User telepohone number", "null"=>true, "default"=>null],
		"username" => ["type"=>"string", "subtype"=>"username", "verbose_name"=>"Username"],
		"sha1_password" => ["type"=>"string", "verbose_name"=>"Password"],
		
        	// Photograph of the user. Stored as a blob in database
		"main_photo" => ["type"=>"blob", "verbose_name"=>"User photo", "null"=>true, "default"=>null],
		"main_photo_mimetype" => ["type"=>"string", "verbose_name"=>"Mimetype of main_photo", "default" =>"application/octet-stream"],
		"main_photo_filename" => ["type"=>"string", "verbose_name"=>"Filename of main_photo", "null"=>true, "default"=>null],
		
        	// Datetime fields
		"last_update_datetime" => ["type"=>"string", "subtype"=>"datetime", "verbose_name"=>"Last update of this object", "auto"=>true],
		"creation_datetime" => ["type"=>"string", "subtype"=>"datetime", "verbose_name"=>"Creation datetime of this object", "auto"=>true],
	];
	
	
	/** Primary key */
	protected static $PK_ATTRIBUTES = ["stack", "id"];
	
	
	/**
	 * Related models.
	 * */
	protected static $RELATED_MODELS = ["Tag", "Photo", "Post"];
	
	
	/** Relationships */
	protected static $RELATIONSHIPS = [
	
	];
}
User::init();