If you like, I've been slowly working on
this guide.
Or, in short, for just your question:
Database SQL Statements
You’ll need to have access to the registry first, in whatever function you're dealing with, of course.
PHP Code:
$mysidia = Registry::get("mysidia");
Counting RowsCount how many rows match a specific query:
PHP Code:
$mysidia->db->select("Table", array("Column"), "Row='{$somevalue}' and Row >= {$somevalue}")->rowCount();
Compare to:
Code:
SELECT COUNT(Row) FROM Column WHERE Row='$somevalue' and Row >= {$somevalue};
Where DataFetching an exact value in a specified column:
PHP Code:
$mysidia->db->select("Table", array("Column"), "Row = '$somevalue'")->fetchColumn();
Compare to:
Code:
SELECT Column FROM Table WHERE Row='$somevalue';
Fetching Row Data as an ObjectExample:
PHP Code:
$pet = $mysidia->db->select("owned_adoptables", array(), "owner='{$mysidia->user->username}' ORDER BY RAND() LIMIT 1")->fetchObject();
You could now use {$pet->name} and {$pet->currentlevel}, etc. (This example chooses a random pet owned by the user.)
Creating a New Row of DataExample:
PHP Code:
$mysidia->db->insert("Table", array("Column" => $somevalue, "Column" => 'somevalue'));
Compare to:
Code:
INSERT INTO table_name (Column1, Column2, Column3) VALUES ($somevalue1, $somevalue2, $somevalue3);
Updating Data
PHP Code:
$mysidia->db->update("Table", array("Column" => '$somevalue'), "Row = '$somevalue'");
Compare to:
Code:
UPDATE Table SET Column='$somevalue' WHERE Row='$somevalue';