AutoPulse; A simple CRUD Library
Database Connection All methods and commands in this library requires an active database connection. You can define your connection witg MySqlConnect or DbConnect class. You can read more about connecting a database Here or Here
Required Namespace
  • Ness
    • Autopulse
      • Autopulse

You can include this library to your code file by typing the below code;

use Ness\Autopulse\Autopulse


Database: Autopulse Library #top

With this library you can easily access and manage your database.

This class, contains functions that make it easier to process your data. AutoPulse will save you writing complex dml queries. The only think you need is to call required function.


Load a model to database #top

This function is used to load a model class directly to your database.

Autopulse::LoadModel(Mixed $modelForm, DbConnect | MySqlConnect  $dbclassinstance);
                        

$modelForm: Model class posted from view
$dbclassinstance: An active database connection source.
Warning If you want to use LoadModel method, your model Class name must be same with your table name and variables defined in model class must be same with column names in your table.


Load an array to database #top

This function is used to load an array to your database.

Autopulse::LoadArray(String  $tableName = '', Array  $fieldList,  DbConnect | MySqlConnect  $dbclassinstance);
$tableName: Table name
$fieldList: Fields with values. array key must be column name of table.
$dbclassinstance: An active database connection source.


Update data #top

Update a data using arrays

Autopulse::Update(Mixed   $tableName, Array   $fieldList = null, String   $whereOption = null,   DbConnect | MySqlConnect $dbclassinstance);
$tableName: Table name to update.
$fieldList: Fields with values. array key must be column name of table.
$whereOption: Update where...
$dbclassinstance: An active database connection source.


Delete a record #top

Delete from database

                                Autopulse::Delete(Mixed   $TableName, DbConnect | MySqlConnect $dbclassinstance,String   $whereOption = null);
                            
$TableName: Table name to delete from.
$whereOption: Update where...
$dbclassinstance: An active database connection source.


Delete record using Model #top

Delete from database

                                Autopulse::Delete(Mixed   $modelForm, DbConnect | MySqlConnect $dbclassinstance,String   $whereOption = null);
                            
$modelForm: Model Form, Autopulse library use this for getting table name from class name.
$whereOption: Update where...
$dbclassinstance: An active database connection source.


Example #top

Let's create a Autopulse command to insert an array to "User" table.


    use Ness\Autopulse\Autopulse;
    /** 
    * OTHER CODES
    **/  
    
    $cons = omap::GetValue("database_1");
    
    $myconnnection = new MySqlConnect($cons["host"],$cons["user"],$cons["password"],$cons["database"]);
        $myUser = array("userid"=>null,
                        "name"=>"Example",
                        "surname"=>"RECORD",
                        "email"=>"test@test.com");
        
        if(Autopulse::LoadArray("user", $myUser, $myconnnection->Source()))
        {
            echo "User Saved";
        }else{
            echo "Error while saving user";
        }