Skip to content

Latest commit

 

History

History
26 lines (16 loc) · 732 Bytes

sqlstatement.md

File metadata and controls

26 lines (16 loc) · 732 Bytes
sidebar_position
3

SQL Statement

The SqlStatement class provides an abstraction for executing SQL queries on the database.

<?php

$dbDriver = Factory::getDbInstance("mysql://user:password@server/schema");
$sql = new SqlStatement("select * from table where field = :param");

$iterator = $sql->getIterator($dbDriver, ['param' => 'value']);

Advantages of Using SqlStatement

  • Reusability: The same SQL statement can be reused with different parameters, reducing the overhead of preparing new queries.
  • Performance: Reusing statements helps optimize performance by leveraging caching mechanisms.
  • Caching Support: Queries can be cached for even faster retrieval (see Cache results).