DrupalBin
Submit Code
About
Recent Posts
TwitterFeed for D4D review
text
rewrite
Module to overrule the save settings of the "new node" form
Code
apidoc
Empty DateTime Object
Fix for listcars_manufacturer.module
listcars_manufacturer.info
listcars_manufacturer.module
more
User login
Log in using OpenID:
What is OpenID?
Username:
*
Password:
*
Log in using OpenID
Cancel OpenID login
Create new account
Request new password
Tags
CCK
drupal
fapi
jquery
menu
module
php
simpletest
test
theme
user
views
more tags
Home
›
Fix for Create a Node from a another Mysql DB Data
Fix for Fix for Create a Node from a another Mysql DB Data
View
Fix
Fixes are not saved to the database until you submit.
Summary:
Tags:
Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Show summary in full view
<?php //exec("/usr/bin/clear"); include_once('includes/bootstrap.inc'); drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); bootstrap_invoke_all('init'); ini_set('memory_limit', '512M'); //echo "Bootstrap sucessfull\n\n"; db_set_active('ssb'); $results = db_query("SELECT * from beschaeftigung WHERE `id_art_beschaeftigung` =2"); db_set_active('default'); while($ssbdaten = db_fetch_array($results)){ $bezeichnung = $ssbdaten["bezeichnung_de"]; $ansprechpartner_name = $ssbdaten["ansprechpartner_name"]; $beschreibung_de = $ssbdaten["beschreibung_de"]; $bereich = $ssbdaten["id_bereich_beschaeftigung"]; $node = new stdClass(); $node->title = "$bezeichnung"; $node->type = "praktikumsplatz"; // all content types have names which are given at the time of the content type creation. visible at content types page when you drag your mouse over the list of content types $node->name = "Admin";//not necessary $node->body = "$beschreibung_de"; // You can remove the body field from your content type if you want. //$node->field_bereich-> = array(array('value' => $bereich)); $node->status = 1;//stands for published=1 or unpublished=0 content $node->uid = 1;//uid is user id, the user id 1 being the id of the one who makes first id after a drupal installation, uid 1 has all prvilleged, make sure your user id comes with all privileges,preferably use userid 1 to save yourself from the hassle. $node->promote = 1; // promote =0 doesn't promote the content to the front page , whereas promote=1 promotes the content to the front page $node->comment = 0; // comment 0=off , comment 1=readonly, comment 2=allowed $node->language = 'de'; // Spracheinstellung //$node->field_friendlytitle = array(array('value' => "$a4" ));// field_friendlytitle is the field I presumably created using cck for the content type. Notice how I am filling in the value for field_friendlytitle using array in an array. $node->format = '2'; // inputformat, format=1 means Filtered HTML,format=1 means PHP code , format=2 means Full HTML $node->field_ansprechpartner_name[0]['value'] = $ansprechpartner_name; // CCK Field //You can also specify $node['nid'] followed by a number which will be the nid but I presume that it wont be of use to you at the moment. Not mentioning it will lead to a sequential auto generation whereas mentioning a static number will overwrite the old content each type you save the node!; $debug = 0; //$debug = 1; if ($debug == 0) { node_save($node); print $node->title.'... Saved<br><hr>'; } elseif ($debug == 1) { print '<pre>'; // print_r($results); print_r($node); print '</pre>'; } //print_r($node)."<br>"; //unset($node); } ?>
Syntax highlighting mode:
ActionScript
ColdFusion
Diff
Drupal 5
Drupal 6
HTML
INI
Javascript
MySQL
PHP
Python
robots.txt
SQL
Text
Select the syntax highlighting mode to use.
See Also:
Order
Title:
URL:
-1
0
1
Title:
URL:
-1
0
1
Any links you'd like to have associated with the post (Drupal.org issue, Wikipedia article, etc).
File attachments
Changes made to the attachments are not permanent until you save this post. The first "listed" file will be included in RSS feeds.
Attach new file:
The maximum upload size is
1 MB
. Only files with the following extensions may be uploaded:
jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp
.