/**
  * Test loadObjectList method
  *
  * @return  void
  *
  * @since   11.1
  */
 public function testLoadObjectList()
 {
     $query = $this->object->getQuery(true);
     $query->select('*');
     $query->from('jos_dbtest');
     $query->order('id');
     $this->object->setQuery($query);
     $result = $this->object->loadObjectList();
     $expected = array();
     $objCompare = new stdClass();
     $objCompare->id = 1;
     $objCompare->title = 'Testing';
     $objCompare->start_date = '1980-04-18 00:00:00';
     $objCompare->description = 'one';
     $expected[] = clone $objCompare;
     $objCompare = new stdClass();
     $objCompare->id = 2;
     $objCompare->title = 'Testing2';
     $objCompare->start_date = '1980-04-18 00:00:00';
     $objCompare->description = 'one';
     $expected[] = clone $objCompare;
     $objCompare = new stdClass();
     $objCompare->id = 3;
     $objCompare->title = 'Testing3';
     $objCompare->start_date = '1980-04-18 00:00:00';
     $objCompare->description = 'three';
     $expected[] = clone $objCompare;
     $objCompare = new stdClass();
     $objCompare->id = 4;
     $objCompare->title = 'Testing4';
     $objCompare->start_date = '1980-04-18 00:00:00';
     $objCompare->description = 'four';
     $expected[] = clone $objCompare;
     $this->assertThat($result, $this->equalTo($expected), __LINE__);
 }
Exemple #2
0
 /**
  * Get document titles for selected paths.
  *
  * @param array $paths relative paths
  * @return array stdClass with params title and path (title can be empty if file hasn't document)
  */
 public function getPathsDocsTitles($paths)
 {
     $paths = $this->getQuotedArray($paths);
     if (!count($paths)) {
         return array();
     }
     $query = 'SELECT `title`, `path`, `full_alias` ';
     $query .= 'FROM `#__joomdoc_flat` AS `document` ';
     $query .= 'WHERE `path` IN (' . implode(', ', $paths) . ') AND ((' . JoomDOCModelList::getDocumentPublished() . ') OR `document`.`id` IN (NULL, 0))';
     $this->_db->setQuery($query);
     return $this->_db->loadObjectList();
 }
 /**
  * Get the details list of keys for a table.
  *
  * @param   string  $table  The name of the table.
  *
  * @return  array  An arry of the column specification for the table.
  *
  * @since   11.1
  *
  * @throws  Exception
  * @todo    Move into database connector class.
  */
 protected function getKeys($table)
 {
     if (empty($this->cache['keys'][$table])) {
         // Get the details columns information.
         $this->db->setQuery('SHOW KEYS FROM ' . $this->db->quoteName($table));
         $this->cache['keys'][$table] = $this->db->loadObjectList();
         // Check for a db error.
         if ($this->db->getErrorNum()) {
             throw new Exception($this->db->getErrorMsg());
         }
     }
     return $this->cache['keys'][$table];
 }
Exemple #4
0
$options = array("host" => $config->host, "user" => $config->user, "password" => $config->password, "database" => $config->db, "prefix" => $config->dbprefix);
$database = new JDatabaseMySQL($options);
$sql = " SELECT ordering FROM #__guru_days WHERE id = " . $day_id;
$database->setQuery($sql);
if (!$database->query()) {
    echo $database->stderr();
    return;
}
$ordering = $database->loadResult();
$sql = " SELECT id, days, tasks FROM #__guru_programstatus WHERE pid = (SELECT pid FROM #__guru_days WHERE id = '" . $day_id . "')";
$database->setQuery($sql);
if (!$database->query()) {
    echo $database->stderr();
    return;
}
$ids = $database->loadObjectList();
foreach ($ids as $one_id) {
    $task_array = explode(';', $one_id->tasks);
    $old_task_array = $task_array[$ordering - 1];
    if ($old_task_array == '') {
        $new_task_array = $old_task_array . $screen_id . '-0';
    } else {
        $new_task_array = $old_task_array . ',' . $screen_id . '-0';
    }
    $task_array[$ordering - 1] = $new_task_array;
    $new_task_array = implode(';', $task_array);
    $sql = "update #__guru_programstatus set tasks='" . $new_task_array . "' where id =" . $one_id->id;
    $database->setQuery($sql);
    $database->query();
}
$sql = "INSERT INTO `#__guru_mediarel` (`type`,`type_id`,`media_id`) VALUES ('dtask','" . $day_id . "','" . $screen_id . "')";