Grand Vision



( ZN >= 4.0.0

The Grand Vision is basically a system created by automatically generating a model file for each table in the database and checking these tables with these model files.

 

 

# Section Headings


# Vision Models Create
# created using the Vision Model
# Vision Files to Delete

 

 

# Creating Vision Models


Use the Generate :: grandVision () method to transform your tables into model files . After running this method, model files are added into the Models / Visions / directory. How to use the specified method  is described in the Generate Library section. Vision takes the last occurrence while creating the Vision files .

Parameters
Array $ databases = NULL If this value is not specified, all databases are considered.
return Bool
Use of
Generate::grandVision(['current_database', 'other_database']);

If some of the databases contain different settings, you can use them as follows.

Generate::grandVision(['db' => ['user' => 'user', 'password' => 'pass'], 'otherdb']);
Console Usage
php zerocore run-class generate:grandvision current_database other_database

With the code above, the current_database and other_database databases have been turned into grand vision model files.

Models/Visions/
    -> Current_database/
        -> InternalUserVision.php
        -> InternalProductVision.php
    -> Other_database/
        -> InternalOther_databaseUserVision.php
        -> InternalOther_databaseProductVision.php

In the above directory view it is shown that a directory is created for each database and a file is created in the tables belonging to that database. Vision models for the default database setting do not take the database prefix, while other databases take the prefix from the table name first. Also all vision models take Vision last add.

 

 

# Using the created Vision Models


To use the vision files in the example above;

output( UserVision::result() );
output( ProductVision::result() );
output( Other_databaseUserVision::result() );
output( Other_databaseProductVision::result() );

. Note that the table prefix for the default database is not fetched, but the database name is prefixed for the other database. The last element of Vision is used to recognize that the class being used is the vision model and not to conflict with other libraries of the same name . These model files created use the methods of extending GrandModel .

 

 

# Delete Vision Files


Use the Generate :: deleteVision () method to delete the vision files .

Parameters
Array $ databases = '*' Which databases will be deleted. The default * will delete all visions if used.
Array $ tables = NULL Which tables will be erased.
return Bool
Use of
Generate::deleteVision(); // Deleted All

You can use the following to delete the specified tables of a database.

Generate::deleteVision('ExampleDB', ['blog', 'comments']); 
Console Usage
php zerocore run-class generate:deletevision
php zerocore run-class generate:deletevision exampledb