Developer Center

Exec and Query

EXEC

It written as WDB::exec(arg1) 

It is used to write "CREATE, ALTER TABLE, DROP" and similar code structures into "arg1". When it runs, it sends a query to the database.

Sample PHP Code

<?php 
    $operation = WDB::exec("CREATE table sample1(
        id INT( 11 ) AUTO_INCREMENT PRIMARY KEY,
        Name VARCHAR( 250 ) NOT NULL,
        StreetA VARCHAR( 150 ) NOT NULL, 
        StreetB VARCHAR( 150 ) NOT NULL, 
        StreetC VARCHAR( 150 ) NOT NULL, 
        County VARCHAR( 100 ) NOT NULL,
        Postcode VARCHAR( 50 ) NOT NULL,
        Country VARCHAR( 50 ) NOT NULL);");

    if($operation)
    {
        echo "Successful";
    }
    else
    {
        echo "Error : ".$operation->getErrorMessage();
    }
    
?>

QUERY

It written as WDB::query(arg1)

Runs SQL queries that you write in "arg1" without using "BUILD" query generation methods. When it runs, it immediately sends a query to the database.

Sample PHP Code

<?php 
    $operation = WDB::query("UPDATE table1 SET field1='apple' WHERE field1='pear' ");

    if($operation)
    {
        echo "Successful";
    }
    else
    {
        echo "Error : ".$operation->getErrorMessage();
    }
    
?>
Number of Rows Table Existence Check

Do you have any questions?

Feel free to contact us
Contact Us
Copyright © 2024. All Rights Reserved.
Join Our Discord Channel
Top