Skip to content

Instantly share code, notes, and snippets.

@d1i1m1o1n
Created February 19, 2016 08:38
Show Gist options
  • Save d1i1m1o1n/7848aeefb83042c3cbe5 to your computer and use it in GitHub Desktop.
Save d1i1m1o1n/7848aeefb83042c3cbe5 to your computer and use it in GitHub Desktop.
Bitrix(d7). DB query
<?php
use Bitrix\Main\Application;
$connection = Application::getConnection();
$sqlHelper = $connection->getSqlHelper();
$sql = "SELECT ID FROM b_user WHERE LOGIN = '".$sqlHelper->forSql($login, 50)."'";
//$connection->query($sql, $limit);
//$connection->query($sql, $offset, $limit);
$recordset = $connection->query($sql);
while ($record = $recordset->fetch())
{
//do something
}
//---------------
$recordset->addFetchDataModifier(
function ($data)
{
$data["NAME"] .= "!";
return $data;
}
);
while ($record = $recordset->fetch(\Bitrix\Main\Text\Converter::getHtmlConverter()))
{
$data[] = $record;
}
//------------
$cnt = $connection->queryScalar("SELECT COINT(ID) FROM table");
$connection->queryExecute("INSERT INTO table (NAME, SORT) VALUES ('Название', 100)")
<?php
global $DB;
$sql = 'SELECT * FROM table';
$res = $DB->Query($sql, false,"<b>Error in </b><br/>File: ".__FILE__."<br/>Line: ".__LINE__."<br/>");
//$res->fetch()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment