Login +

Release Notes / 1.0.7

Introduction

SillySmart 1.0.7 introduces 33 new features & bug fixes.

To browse the full list, check the roadmap :

http://redmine.sillysmart.org/versions/48

Controller

We can now choose a default action foreach Controller.

We can access to this default action by only informing the Controller in the URL.

For exemple, http://vhost.domain.tld/Home/ reroute on http://vhost.domain.tld/Home/Index

Model

Filters

Creating a system of filters on Model.

Assign a filter on a column allow to filter the values ​​passed automatically to different setters before the validation process (native types, specific types, integrity constraints, uniqueness, etc.).

The filters are cumulative and process in the order they were completed.

Available filters:

  • Alnum
  • Alpha
  • Numeric
  • Lowercase
  • Uppercase
  • Ucfirst
  • Lcfirst
  • ucwords
  • rTrim
  • lTrim
  • Trim
  • Nospace
  • Sanitize
  • Hash|Type
  • Striptag

We can specify filters at Model level:

Specific type "IP"

The specific type IP address can now be declined in 3 variants (IP V4, IP V6, both)

Multilanguage

On multilingual Model, you can now specify any column as not multilingual. This avoids to appear these columns on User Bo only on the default language. This is the value entered in this language that will be cloned in all the other languages ​​of your application.

Back-Office

- No multilingual fields not appear more in other languages than the default.

- Adding a new JS generic object containing all columns, their types, their specific types, their constraints, filters, etc.. This object is called slsBoBuild :

var slsBoBuild = {
    'langs' : {
        'en' : {
            'user_email' : {
                'id' : 'user_email_en',
                'required' : true,
                'max_length' : 255,
                'label' : 'Email',
                'type' : 'string',
                'filters' : ['lower', 'trim'],
                'specific_type' : 'email'
            },
            /* ... */
        }
    }
};

SLS_ExprBuilder1

New class for formatting comparison expressions used in SQL queries.

  • protectColumn($col) allow to escape columns names and isolate alias tables
  • eq($col,$value) allow to format `$col` = '$value'
  • neq($col,$value) allow to format `$col` != '$value'
  • lt($col,$value) allow to format `$col` < '$value'
  • lte($col,$value) allow to format `$col` <= '$value'
  • gt($col,$value) allow to format `$col` > '$value'
  • gte($col,$value) allow to format `$col` >= '$value'
  • isNull($col) allow to format `$col` IS NULL
  • isNotNull($col) allow to format `$col` IS NOT NULL
  • like($col,$value) allow to format `$col` LIKE '%$value%'
  • nlike($col,$value) allow to format `$col` NOT LIKE '%$value%'
  • in($col,$value) allow to format `$col` IN ('$value1', '$value2',…)

SLS_QueryBuilder2

New class to create complex MySQL queries.

The following code examples show all the functions you can use to construct queries.

The expr() function of SLS_QueryBuilder2 class is a interface function with SLS_ExprBuilder1 class.

That this is the execute() function that will submit your request. So you can work continuously with your object before calling execute() function.

$qbd = new SLS_QueryBuilder();

// Select
$resu = $qbd->select('news_id','news_title','news_date')
            ->from('news')
            ->innerJoin('user', $qbd->expr()->eq('news.user_id', 'user.user_id'))
            ->where($qbd->expr()->like('news_title','%e%'))
            ->whereOr($qbd->expr()->like('news_title','%a%'))
            ->groupBy("news_id")
            ->having($qbd->expr()->in('news_id',array(49,69,89,15)))
            ->order(array("news_title","news_date"),array("desc"))
            ->limit(1,10)
            ->execute();
# $resu should contain an array of PDO recordsets

// Update
$resu = $qbd->update()
            ->from('keyword')
            ->set($qbd->expr()->eq('keyword_name','updated'))
            ->where($qbd->expr()->eq('keyword_id','1'))
            ->execute();
# $resu should contain an int representing the number of recordsets updated

// Delete
$resu = $qbd->delete()
            ->from('keyword')                   
            ->where($qbd->expr()->eq('keyword_id','3'))
            ->execute();
# $resu should contain an int representing the number of recordsets deleted

SLS_String3

Added objectToArray() function which allows to cast Std Class (native object implemented by PDO) in array. The interest is to do the reverse treatment of arrayToObject() function.

Prototype:

public array objectToArray($object)

Return:

array $array

SLS_Bo

Adding a maintenance mode in the SillySmart Back Office, it toggles all the actions of the site on the new error page 302 (MaintenanceError).

The authenticated admins on the SillySmart back office can still access all the application to debug if necessary.

Various

- The stack traces in development mode are now enriched of values ​​of various parameters of functions called (var, array, object supported)

- Page title are now formed as follows "title action | projectname"

References

  1. SLS_ExprBuilder - SLS_ExprBuilder class
  2. SLS_QueryBuilder - SLS_QueryBuilder class
  3. SLS_String - Tool SLS_String - String Treatment