Exemplo n.º 1
0
 public function get_app_path_from_project_id($project_id)
 {
     $request = odDatabaseRequest::getInstance();
     $request->makeSelectRequest(['*'], ['orchid_bo_projects'], [['id', 'E', $project_id]]);
     $result = $request->runQuery();
     $row = $request->nextRow($result);
     return $row["project_path"];
 }
Exemplo n.º 2
0
 public function export_database_datas($filename, $tables, $option = "drops")
 {
     // Instanciation de l'outil de fabrication des requêtes
     $request = odDatabaseRequest::getInstance();
     $filename .= ".xml";
     // Utilisation de la base concernée
     $request->makeRequest("USE " . $this->_basename);
     $result = $request->runQuery();
     //get all of the tables
     if ($tables == '*') {
         $tables = array();
         $request->makeRequest("USE " . $this->_basename . "; SHOW TABLES FROM " . $this->_basename);
         $result = $request->runQuery();
         while ($row = $request->nextRow($result)) {
             array_push($tables, $row['Tables_in_' . $this->_basename]);
         }
     } else {
         $tables = is_array($tables) ? $tables : explode(',', $tables);
     }
     $file = new odFile($filename);
     $file->write("<?xml version='1.0' encoding='utf-8'?" . chr(62));
     $file->write('<base_definition>');
     $file->write('<model>mysql</model>');
     if ($option == "drops") {
         $file->write('<deletes>');
         foreach ($tables as $table) {
             $file->write('<delete_request>DELETE FROM ' . $table . ';</delete_request>');
         }
         $file->write('</deletes>');
     }
     $file->write('<inserts>');
     foreach ($tables as $table) {
         $request->select_all_on($table);
         $result = $request->runQuery();
         $field_count = $request->fieldCount();
         while ($row = $request->nextRowArray($result)) {
             $file->write('<insert_request>');
             $file->write('<![CDATA[INSERT INTO ' . $table . ' VALUES(');
             for ($i = 0; $i < $field_count; $i++) {
                 $row[$i] = addslashes($row[$i]);
                 $row[$i] = preg_replace("/\n/", "\\n", $row[$i]);
                 if (isset($row[$i])) {
                     $file->write('"' . utf8_encode($row[$i]) . '"');
                 } else {
                     $file->write('""');
                 }
                 if ($i < $field_count - 1) {
                     $file->write(',');
                 }
             }
             $file->write(');]]>');
             $file->write('</insert_request>');
         }
     }
     $file->write('</inserts>');
     $file->write('</base_definition>');
     $file->close();
 }
Exemplo n.º 3
0
 public function makeRequest($req)
 {
     self::$request = $req;
 }