Tutorials & ManualsSQL YogaSQL Yoga SQL Query ObjectsHow Do I Delete Records From the Database Table Using a SQL Query Object?

How Do I Delete Records From the Database Table Using a SQL Query Object?

A SQL Query object provides a quick way of deleting data from a database. This lesson will show you how to use sqlquery_delete to do so.

Note: When using sqlquery_delete none of the validations or callbacks you've defined for Table objects will be triggered.

Create An Object

The first step is to create a SQL Query object that can be passed to sqlquery_delete.

sqlquery_createObject("lessons") into theQueryA

Define Conditions

When calling sqlquery_delete, the where clause property of the SQL Query object will be used to perform the delete. You define this property by setting the conditions property using sqlquery_set.

## Specify that lesson with an id of 12 should be deleted.

sqlquery_set theQueryA, "conditions", "id is :1", 12

Delete

## Perform the delete.

sqlquery_delete theQueryA

put the result into theError

put it into theAffectedRows

0 Comments

Add your comment

E-Mail me when someone replies to this comment