-
-
Save codezixo/1f6075229534fed798885c8a4d828bfa to your computer and use it in GitHub Desktop.
Bitrix(d7). DB query
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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)") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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