_PUIKA_ Posted September 29, 2011 Report Share Posted September 29, 2011 Labdien. Vakarnakt saskāros ar problēmu, rakstot wordpress spraudni. Ieskatam, re: Galvenais index.php fails (galvene ar spraudņa informāciju šeit nav iekļauta) Fails pieprasa funckciju failu.. // Asking for functions (constants, setups, etc.) require_once( ABSPATH . "wp-content/plugins/sarsauto/includes/functions.php" ); Tālāk.. funkciju fails (definēju mapes un pieprasu pārbaudīt instalācijas failu) tik tālu viss ok.. // Defining plugin's root directory's constant name define( "dSARSAUTO", ABSPATH . "wp-content/plugins/sarsauto/" ); // Defining plugin's includes directory's constant name define( "dINCLUDES", dSARSAUTO . "includes/" ); // /* END OF CONSTANTS */ /* SETUPS */ // // Asking for setup.php file and if exists create function if( file_exists( dINCLUDES . "setup.php" ) ){ // Require setup.php file include( dINCLUDES . "setup.php" ); // On plugin activation ask for table setup function register_activation_hook( __FILE__, "sarsauto_table_setup" ); }else{ echo "Error: file doesn't exists!"; } Un te ir arī pats instalācijas fails: // Setting up table version for later upgrades global $sarsauto_version; $sarsauto_table_version = "0.1.beta"; // Creating table function sarsauto_table_setup() { global $wpdb; global $sarsauto_table_version; $table_name = $wpdb->prefix . "sarsauto"; if( $wpdb->get_var( "show tables like '$table_name'" ) != $table_name ){ $sql = "CREATE TABLE " . $table_name . " ( id int(11) NOT NULL AUTO_INCREMENT, UNIQUE KEY id (id) );"; } // The dbDelta function examines the current table structure, // compares it to the desired table structure, and either adds // or modifies the table as necessary. require_once( ABSPATH . "wp-admin/includes/upgrade.php" ); dbDelta( $sql ); add_option( "sarsauto_table_version", $sarsauto_table_version ); } Tātad, pie spraudņa palaišanas funkciju failā IF funkcija pārbauda vai instalācijas fails eksistē, un ja eksistē, tad notiek tā faila integrēšana un galvenā tabulu instalācijas funkcija tiek izsaukta, kura principā pārbauda vai tabula eksistē, un ja nē, tad laižam SQL query, It kā visam vajadzētu iet, bet kad pārbaudu /phpmyadmin/ wordpress datubāzes tabulu sarakstu, nekādu izmaiņu (t.i. tabula 'sarsauto' neizveidojas). Kāds zin kas par vainu? Paldies jau iepriekš. Ričards :) p.s. atvainojos par angļu valodu komentāros (praktizēju). Quote Link to comment Share on other sites More sharing options...
laucinieks Posted October 17, 2011 Report Share Posted October 17, 2011 (edited) Tev if'a SQL ir nepareizs. Bez if'a viss iet. Paprovē samainīt if'a sql uz - "SHOW TABLES FROM '".$table_name." LIKE '".$row_name."'"; AC, L. EDIT: nepaskatījos uz datumu, atvainojos ! Edited October 17, 2011 by laucinieks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.