Please remember before running any query inside code,please test your query in admin module .
for example your query is wrong there
SELECT Contract WHERE name LIKE '%A%'
For example you want to count number of user request open then query for this like
$sOQL='SELECT UserRequest WHERE org_id = :org_id AND status NOT IN ("closed", "resolved")';$oSearch=DBObjectSearch::FromOQL($sOQL);$iUser=UserRights::GetContactId();if($iUser>0){$oSearch->AddCondition('caller_id',$iUser);}$oSet=newCMDBObjectSet($oSearch,array(),array('org_id'=>$oUserOrg->GetKey()));return$oSet->Count();
ok i hope this will help you
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
Can someone please show me how i can execute an SQL query from within the Contract Class.
Currently i am trying:
~~~~~~~
$sSQL = "SELECT name from contract'";
$resQuery = CMDBSource::Query($sSQL);
$aRow = mysqli_fetch_assoc($resQuery);
~~~~~~~~
But unfortunately this returns errors:
Error: Failed to issue SQL query: query = SELECT name from contract', mysql_error = , mysql_errno = 0.
Any help please?
Hi jitsobullet,
Please remember before running any query inside code,please test your query in admin module .
for example your query is wrong there
SELECT Contract WHERE name LIKE '%A%'
For example you want to count number of user request open then query for this like
ok i hope this will help you