Quick links: Content - sections - sub sections
EN FR

Managing schemas

The class jDbSchema allow you to manipulate the structure of the database. It have some methods to create a table, to retrieve the structure of a table etc. It uses some other tables: jDbTable and jDbColumn.

This classes are experimentals and all drivers don't support them.

You can retrieve a jDbSchema object by calling the method schema() of a jDbConnection object.

See the API documentation.

Executing an SQL script

If you want to execute a SQL script containing several queries, you can call the execSQLScript() method of the object jDbTools. You retrieve this object by calling the method tools() of a connection object.


  $conn = jDb::getConnection();
  $conn->tools()->execSQLScript('/path/to/a/script.sql');

In order to use the table prefix indicated in the profile, it is strongly recommended to use the %%PREFIX%% tag before each name of tables. It will be replaced by the prefix (or by nothing if there is no prefix).


UPDATE %%PREFIX%%product.....;
INSERT .....;

jDbWidget

jDbWidget is a class providing useful methods.


  $dbw = jDb::getDbWidget(); // instead of getConnection()

  $record = $dbw->fetchFirst("SELECT name, first_name FROM user");
  
  $liste = $dbw->fetchAll("SELECT name, first_name FROM user");

For other methods of jDbWidget, see the API reference.