Skip to content

Instantly share code, notes, and snippets.

@codezixo
Forked from d1i1m1o1n/d7.php
Created June 21, 2022 01:29
Show Gist options
  • Save codezixo/1f6075229534fed798885c8a4d828bfa to your computer and use it in GitHub Desktop.
Save codezixo/1f6075229534fed798885c8a4d828bfa 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