kytschBASIC

Put down that phone!
Please view me on real computer.

DBIND

When performing a query you often need to pass data in to said query, this is where the bind command comes into play.

Example

REM Define the database connection and assign the results to the menu& variable.
DATA menu&
	REM Open the database connection from the config file labelled kytschBASIC.
	DOPEN "kytschBASIC"

	REM Read from the menu table in the database.
	DREAD "menu"

	REM Select all entries from the menu table.
	DSELECT "*"

	REM Condition the select to those that aren't deleted.
	DWHERE "(slug=:header OR slug=:footer) AND deleted_at != NULL"

	REM Bind the slug string to be used in the query.
	DBIND header="header",footer="footer"

	REM Sort the results by their name alphabetically.
	DSORT "name ASC"
END DATA

REM Loop through the results stored in menu& variable.
FOR item& IN menu&
	SWRITE
		PRINT item&["id]
		LINE BREAK
		PRINT item&["name"]
	SWRITE CLOSE
END FOR

Output

<span>2</span>
<span>About</span>
<br/>
<span>1</span>
<span>Home</span>
<br/>
<span>3</span>
<span>Installation</span>
<br/>

See also