Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
95 lines (60 sloc) 2.86 KB


Execute an SQL statement using Prepared Statements.


PExecute($sql, $varN)
$sql:The MySQL query to perform on the database
$varN:The variable(s) that will be placed instead of the ? placeholder separated by a ',' or it can be the method Prepare.
.. seealso::

  `SQL syntax prepared statements <>`_.

Like the Execute Method, in most cases you probably only use this method when Inserting or Updating data for retrieving data you can use:

method Description
PgetAll Executes the SQL and returns the all the rows as a 2-dimensional array.
PgetRow Executes the SQL and returns the first row as an array.
PgetCol Executes the SQL and returns all elements of the first column as a 1-dimensional array.
PgetOne Executes the SQL and returns the first field of the first row.
PgetASSOC Executes the SQL and returns an associative array for the given query. If the number of columns returned is greater to two, a 2-dimensional array is returnedwith the first column of the recordset becomes the keys to the rest of the rows. If the columns is equal to two, a 1-dimensional array is created, where the the keys directly map to the values.


Notice that when using "Prepared statements" the methods are prefixed with a P.


An Insert example:

An Update example:


When updating the return value 0, Zero indicates that no records where updated.