CMSB v3.63 Beta (ZenDB: Next-Generation Database Library)

6 posts by 2 authors in: Forums > CMS Builder
Last Post: November 7, 2023   (RSS)

By Dave - November 1, 2023 - edited: November 2, 2023

Hi everyone,

We're pleased to announce the arrival of the v3.63 Beta.  We're really excited about this one!

If you've ever had to write (or modify) MySQL code, or if you want to learn, then this will be of special interest to you.

ZenDB: Next-Generation Database Library

ZenDB is a PHP/MySQL database abstraction layer designed to make your development process faster, easier, and more enjoyable. It focuses on ease of use, beautiful code, and optimizing for common use cases while allowing for customization and flexibility when needed.

Some notable features of this library include: 

  • Simple & Intuitive: We mimic MySQL terminology while removing unnecessary complexity, making it easy to learn and use. If you're familiar with MySQL, you'll find this fast and intuitive; otherwise, you'll effortlessly learn MySQL just by using it.
  • Flexible Syntax: Database methods can be called in various ways to meet your specific needs, and they can easily adapt to both quick data lookups and complicated queries, all while keeping your code clean and understandable.
  • Injection Proof SQL: We've made it impossible to write insecure MySQL code, so you never have to worry about escaping user inputs or accidentally introducing a security vulnerability in your code.
  • Automatic HTML-encoding: Along the same lines, we automatically HTML-encode output so you don't have to do that either, with the option to disable it when needed.
  • And so much more.

Here's some sample code that shows the general syntax and some of the different ways these functions can work: 

// load a record by num
$user = DB::get('users', 123);

// load all users
$users = DB::select('users');
foreach ($users as $user) { 
  print "$user->name\n"; // outputs html-encoded name
}

// load matching users with sql and positional placeholders (allows for more complex queries)
$users = DB::select('users', "division = ? AND city = ?", 2, "Vancouver");

// load matching users with sql and named placeholders (allows for even more complex queries)
$where = "category = :cat AND city = :city AND age >= :min AND age <= :max AND job_status = :status"; 
$users = DB::select('users', $where, [
    ':cat'    => 2,
    ':city'   => "Vancouver",
    ':min'    => 21,
    ':max'    => 50,
    ':status' => 'Full-Time'
]);

We've already integrated this into CMS Builder, and rewritten the cron.php dispatcher to use it.  Feel free to give a try and let us know any questions or feedback!

You can find a more detailed document that better describes all the features here:
https://github.com/interactivetools-com/ZenDB/#zendb-phpmysql-database-library

Other CMSB Changes:

  • Hide PHP Errors: If you're logged in to the CMS as an Admin we'll now always show you errors even if "Hide PHP Errors" is enabled
  • Hide PHP Errors: Cron job errors will also no longer hide errors when logging or emailing reports to the developer or server admin (who already has full access)
  • Developer Log: The "Backtrace" field is now "Call Stack" and shows a user-friendly list of function calls to make it easier to pinpoint errors.
  • Developer Log: The initial error file and line reported are from the most likely cause above the cms /lib/ folder, making it easier to track the origin of errors

Here's the complete changelog:

*** October 31, 2023 - Version 3.63 (ZenDB Database Library)

SERVER REQUIREMENTS: PHP 8.0+ and MySQL 5.5+

NEW FEATURES
- ZenDB Database Library - Added new next-generation database library for improved performance and security.

MINOR CHANGES & BUG FIXES
- Developer Log: Replaced "Backtrace" with sequential "Call Stack" to make debugging faster and easier.
- Hide PHP Errors: Now only applies to web requests and displays full errors for cronjobs and logged-in admins.
- showme() no longer outputs HTML tags when Content-type is "text/plain" (for debugging)
- Security: Automatically remove X-Powered-By: PHP/x.x header to prevent information disclosure
- Programmers: Added new plugin filter 'headers' for adding or modifying headers sent to the browser
- Misc Code and other minor improvements.

You can download the latest beta here: https://www.interactivetools.com/order/download.php

Please post any feedback, questions, or bugs you find!

Thanks! :)

Dave Edis - Senior Developer
interactivetools.com

CMSB v3.63 Beta 1 (ZenDB: Next-Generation Database Library)

By Steve99 - November 2, 2023

Dave,

Wow... ZenDB sounds incredible. I've only had time for a cursory review since the beta released, but this looks absolutely brilliant!

Best,
Steve

By Dave - November 2, 2023

Thanks, Steve!  We appreciate the kind words and feedback.  A lot of time went into it! :-)

Dave Edis - Senior Developer
interactivetools.com

By Dave - November 2, 2023

HI All, 

We just released Beta 2 with the following fixes and changes: 

  • Fixed an issue that prevented new installs (thanks to Djulia for reporting!)
  • Fixed an issue that prevented errors from being displayed during the install process
  • Added new method DB::like() for "contains keyword" searches, example:
    $containsKeyword = ​DB::like('sports');
    $rows = DB::select('articles', "title LIKE ?", ​$containsKeyword);
  • Misc code refactoring and text changes

You can download the latest version here: https://www.interactivetools.com/download/

Dave Edis - Senior Developer
interactivetools.com

By Dave - November 3, 2023 - edited: November 3, 2023

Hi All, 

We've just released Beta 3! 

Thanks everyone for the valuable feedback.  Here's what's new and changed: 

  • cron.php - Fixed error with parsing of cron expressions (thanks to Steve)
  • Backup & Restore - Fixed error when not all mysql tables had been created (thanks to Djulia)
  • ZenDB: Renamed methods values and first to getFirst and getValues for readability
  • ZenDB: Added DB::like("keyword") helper function for wildcard keyword searches
  • Email Templates: Added "Attachments" field to email templates to automatically send attachments (suggested by Jeff)
  • Misc code refactoring and text changes

The Email Template attachment feature is pretty neat.  You can test it by adding an attachment to the CMS-PASSWORD-RESET template and then clicking the "Forgot your password" link.  It will include the attachment with the email that's sent.  

You can download the latest version here: https://www.interactivetools.com/download/

Let me know any questions!

Dave Edis - Senior Developer
interactivetools.com