Icon edb_execsql

Executes an SQL statement directly against the current database.

Syntax
edb_execsql(<ConnectionHandle>, <SQL>)

<ConnectionHandle> =

Handle of connection returned by edb_connect function

<SQL> = Valid SQL statement

Returns
Affected row count (where applicable) if successful,
or FALSE if there are any errors

Usage
The edb_execsql function executes an SQL statement directly. This is useful for DDL statements and other statements where you do not need to bind parameters or use the resultant cursor (SELECT statements).

Examples
<?php

// The following script connects to an ElevateDB
// Server and the system Configuration database,
// creates a new database if it doesn't already exist,
// changes to the new database using the edb_changedb()
// function, and then disconnects using the
// edb_disconnect() function

$con = edb_connect("type=remote;charset=Ansi;address=127.0.0.1;"+
                   "uid=Administrator;pwd=EDBDefault;database=Configuration");
if (!$con)
  {
  die("Could not connect: " . edb_errmsg());
  }
echo edb_db($con);
if (edb_execsql($con,"SELECT * FROM Databases WHERE Name='Tutorial'") == 0)
  {
  edb_execsql($con,"CREATE DATABASE Tutorial PATH 'C:\Tutorial'");
  }
edb_changedb($con,"Tutorial");
echo edb_db($con);
edb_disconnect($con);
?>
Image