Skip to content

Latest commit

 

History

History
34 lines (24 loc) · 2.12 KB

File metadata and controls

34 lines (24 loc) · 2.12 KB

SmartArray Documentation

SmartArray wraps your database rows so template code gets shorter and safer at once: filter, sort, and group with chainable methods, and echo fields directly. Fields HTML-encode themselves the moment you output them.

New to SmartArray? The Basics reads in order, and the first two pages alone cover everything a typical list-plus-detail template needs. The other sections are standalone: open whichever matches your task.

The Basics (read in order)

  1. Getting Started - Install, your first collection, loops, single rows, and formatting fields with SmartString methods.
  2. Displaying Fields - Reading fields, fallbacks for blank values with or(), "no results" messages, and the guards that stop the page for required records.
  3. Outputting HTML - How auto-encoding works, trusted HTML with rawHtml(), loop layout with isFirst()/isLast()/position(), and the raw-keys gotcha.
  4. Filtering and Sorting - Narrowing loaded results with where(), whereNot(), whereInList(), and filter(), plus sortBy(), sort(), and unique().
  5. Transforming and Grouping - Reshaping results with column(), indexBy(), groupBy(), map(), and implode().
  6. Using SmartArray Without SmartStrings - Plain-value collections for JSON, CSV, email, and CLI output, converting between modes, and type hints.

Everyday Use

  • Common Patterns - Copy-paste recipes for real template tasks: related names without a join, select dropdowns, grouped headings, id lists for SQL.

Lookup

  • Method Reference - Every method in one place, grouped by what it returns.
  • Troubleshooting - Common error messages and behavior gotchas, with fixes.
  • Performance - What SmartArray costs vs plain arrays: about 0.002 ms per 25-row page and 300 bytes per row.
  • AI Reference - The complete API in one dense file, written for AI coding assistants.

← Back to main README