Esempio n. 1
0
 /**
  * @depends testGet
  * @covers Phramework\LogJSONAPI\Models\QueryLog::getById
  */
 public function testGetById($id)
 {
     $data = QueryLog::getById($id);
     $this->assertNotNull($data);
     $this->assertInternalType('object', $data);
     $this->assertObjectHasAttribute('id', $data);
     $this->assertObjectHasAttribute('type', $data);
     $this->assertObjectHasAttribute('attributes', $data);
     $this->assertSame($id, $data->id);
 }
Esempio n. 2
0
 /**
  * Return only ids
  * @param  string $queryLogId Foreign key
  * @return string[]
  */
 public static function getRelationshipByQueryLog($queryLogId)
 {
     //Access QueryLog object by this id to get the request_id
     $queryLogObject = QueryLog::getById($queryLogId);
     if (!$queryLogObject) {
         return [];
     }
     $requestId = $queryLogObject->attributes->request_id;
     SystemLogAdapter::prepare();
     $table = static::$table = SystemLogAdapter::getTable();
     $schema = SystemLogAdapter::getSchema();
     //Include schema if is set
     $schema = $schema ? sprintf('"%s".', $schema) : '';
     $ids = SystemLogAdapter::executeAndFetchAllArray(sprintf('SELECT "id"
             FROM %s"%s"
             WHERE "request_id" = ?', $schema, $table), [$requestId]);
     return array_map('strval', $ids);
 }