Esempio n. 1
0
 /**
  * Overrides the database connector delete query function
  *
  * @param string $sql 		A full SQL query to run.
  * @param string $prefix 	A table prefix, this will be replaced
  *
  * @return integer Number of rows updated.
  */
 public function delete($table, $where = null)
 {
     if (!$this->isTableTranslatable($table)) {
         return parent::delete($table, $where);
     }
     // Do the language specific table switch on the table
     $table_translated = $table;
     if ($this->_lang_primary != $this->_lang_active) {
         $table_translated = strtolower($this->_lang_active) . '_' . $table_translated;
     }
     // Execute successful update the nodes accordingly
     $result = parent::delete($table_translated, $where);
     if ($result !== false) {
         $parser = new KDatabaseQueryParser(str_replace('WHERE', '', $where));
         $sql = $parser->parseSearchClause();
         $ids = $sql['arg_2']['value'];
         settype($ids, 'array');
         //force the $ids to an array
         $node = KFactory::get('admin::com.nooku.table.nodes');
         $node_data = array('deleted' => 1, 'modified' => $this->getNow(), 'modified_by' => KFactory::get('lib.joomla.user')->id);
         foreach ($ids as $id) {
             $query = $this->getQuery()->where('table_name', '=', $table)->where('row_id', '=', $id);
             $node->update($node_data, $query);
         }
     }
     return $result;
 }