XMF Cookbook
  • Introduction
  • XMF Cookbook
  • Basic Ingredients
    • Namespaces
    • Autoloading
    • Debugging
    • Forward Compatibility
  • Recipes
    • Introducing Module Helpers
    • Using the Permission Helper
      • Checking Permissions
      • Managing Item Permissions
    • Using the Session Helper
    • Using JSON Web Tokens
    • Altering Database Tables
    • Migrating a Module's Database
    • Loading Initial Data
    • Module Admin Pages
      • Hide and Seek with Icons
      • Standard Admin Pages
    • Manage Metadata
    • Highlighting Content
  • Reference
    • Assert
      • Assertions
    • Database
      • Migrate
      • TableLoad
      • Tables
        • Getting Started
        • Table Operations
        • Working with Columns
        • Working with Indexes
        • Changing Table Data
        • Interacting with the Work Queue
        • Error Info and Debugging
    • Debug
    • FilterInput
    • Highlighter
    • IPAddress
    • Jwt
      • JsonWebToken
      • KeyFactory
      • TokenFactory
      • TokenReader
    • Key
      • ArrayStorage
      • Basic
      • FileStorage
      • KeyAbstract
      • StorageInterface
    • Language
    • Metagen
      • Extracting Data
      • Applying Data
    • Module
      • Admin
      • Helper
      • Helper
        • AbstractHelper
        • Cache
        • GenericHelper
        • Permission
        • Session
    • ProxyCheck
    • Random
    • Request
    • StopWords
    • Uuid
    • Yaml
  • Credits
  • License:
  • Table of Content
Powered by GitBook
On this page
  • TableLoad::loadTableFromArray($table, $data)
  • TableLoad::loadTableFromYamlFile($table, $yamlFile)
  • TableLoad::truncateTable($table)
  • TableLoad::countRows($table, $criteria)
  • TableLoad::extractRows($table, $criteria, $skipColumns)
  • TableLoad::saveTableToYamlFile($table, $yamlFile, $criteria, $skipColumns)
  1. Reference
  2. Database

TableLoad

PreviousMigrateNextTables

Last updated 6 years ago

Xmf\Database\TableLoad is a class to simplify loading initial data to a new table. All methods take a table name as an argument, and that table name will automatically be prefixed as appropriate to the XOOPS system.

These methods are intended for use will small sets of data, as all data will be held in memory during processing.

TableLoad::loadTableFromArray($table, $data)

Loads a table from an array. Each top level element of the array is a single row. Each row consists of an associative array of 'column' => 'value' pairs for each included column.

Returns the count of rows inserted.

TableLoad::loadTableFromYamlFile($table, $yamlFile)

Similar to TableLoad::loadTableFromArray(), but reads the array from the specified YAML file.

This method can accept a YAML export from .

Returns the count of rows inserted.

TableLoad::truncateTable($table)

Empties the specified database table.

Returns the number of affected rows.

TableLoad::countRows($table, $criteria)

Returns the count of rows in a table matching the optional Criteria (all rows in the table if not specified.)

TableLoad::extractRows($table, $criteria, $skipColumns)

Returns an array of rows from $table matching the optional Criteria (all rows in the table if not specified.)

An array of column names that should not be included in the extracted data can be specified in $skipColumns. If not specified, all columns will be included.

TableLoad::saveTableToYamlFile($table, $yamlFile, $criteria, $skipColumns)

Extracts table data from $table matching the optional $criteria (all rows in the table if not specified) and saves it in the YAML file $yamlFile.

An array of column names that should not be included in the extracted data can be specified in $skipColumns. If not specified, all columns will be included.

Returns true on success, false on error.

phpMyAdmin