A PHP Error was encountered

Severity: 8192

Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior

Filename: database/DB_driver.php

Line Number: 1876

A PHP Error was encountered

Severity: 8192

Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior

Filename: database/DB_driver.php

Line Number: 1876

A PHP Error was encountered

Severity: 8192

Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior

Filename: database/DB_driver.php

Line Number: 1876

A PHP Error was encountered

Severity: 8192

Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior

Filename: database/DB_driver.php

Line Number: 1876

A PHP Error was encountered

Severity: 8192

Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior

Filename: database/DB_driver.php

Line Number: 1876

A PHP Error was encountered

Severity: 8192

Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior

Filename: database/DB_driver.php

Line Number: 1876

A PHP Error was encountered

Severity: 8192

Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior

Filename: database/DB_driver.php

Line Number: 1876

A PHP Error was encountered

Severity: 8192

Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior

Filename: database/DB_driver.php

Line Number: 1876

A PHP Error was encountered

Severity: 8192

Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior

Filename: database/DB_driver.php

Line Number: 1876

A PHP Error was encountered

Severity: 8192

Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior

Filename: database/DB_driver.php

Line Number: 1876

A PHP Error was encountered

Severity: 8192

Message: Function create_function() is deprecated

Filename: geshi/geshi.php

Line Number: 4751

A PHP Error was encountered

Severity: 8192

Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior

Filename: database/DB_driver.php

Line Number: 1876

A PHP Error was encountered

Severity: 8192

Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior

Filename: database/DB_driver.php

Line Number: 1876

A PHP Error was encountered

Severity: 8192

Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior

Filename: database/DB_driver.php

Line Number: 1876

A PHP Error was encountered

Severity: 8192

Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior

Filename: database/DB_driver.php

Line Number: 1876

A PHP Error was encountered

Severity: 8192

Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior

Filename: database/DB_driver.php

Line Number: 1876

u - mcpaste

u

Von h, 9 Jahre vorher, geschrieben in Java, aufgerufen 1'543 mal.
URL https://mcpaste.de/view/e82c2305 Einbetten
Paste herunterladen oder Rohtext anzeigen
  1. mport android.content.ContentValues;
  2. import android.content.Context;
  3. import android.database.Cursor;
  4. import android.database.sqlite.SQLiteDatabase;
  5. import java.util.ArrayList;
  6. import java.util.HashMap;
  7.  
  8. public class StudentRepo {
  9.     private DBHelper dbHelper;
  10.  
  11.     public StudentRepo(Context context) {
  12.         dbHelper = new DBHelper(context);
  13.     }
  14.  
  15.     public int insert(Student student) {
  16.  
  17.         //Open connection to write data
  18.         SQLiteDatabase db = dbHelper.getWritableDatabase();
  19.         ContentValues values = new ContentValues();
  20.         values.put(Student.KEY_age, student.age);
  21.         values.put(Student.KEY_email,student.email);
  22.         values.put(Student.KEY_name, student.name);
  23.  
  24.         // Inserting Row
  25.         long student_Id = db.insert(Student.TABLE, null, values);
  26.         db.close(); // Closing database connection
  27.         return (int) student_Id;
  28.     }
  29.  
  30.     public void delete(int student_Id) {
  31.  
  32.         SQLiteDatabase db = dbHelper.getWritableDatabase();
  33.         // It's a good practice to use parameter ?, instead of concatenate string
  34.         db.delete(Student.TABLE, Student.KEY_ID + "= ?", new String[] { String.valueOf(student_Id) });
  35.         db.close(); // Closing database connection
  36.     }
  37.  
  38.     public void update(Student student) {
  39.  
  40.         SQLiteDatabase db = dbHelper.getWritableDatabase();
  41.         ContentValues values = new ContentValues();
  42.  
  43.         values.put(Student.KEY_age, student.age);
  44.         values.put(Student.KEY_email,student.email);
  45.         values.put(Student.KEY_name, student.name);
  46.  
  47.         // It's a good practice to use parameter ?, instead of concatenate string
  48.         db.update(Student.TABLE, values, Student.KEY_ID + "= ?", new String[] { String.valueOf(student.student_ID) });
  49.         db.close(); // Closing database connection
  50.     }
  51.  
  52.     public ArrayList<HashMap<String, String>>  getStudentList() {
  53.         //Open connection to read only
  54.         SQLiteDatabase db = dbHelper.getReadableDatabase();
  55.         String selectQuery =  "SELECT  " +
  56.                 Student.KEY_ID + "," +
  57.                 Student.KEY_name + "," +
  58.                 Student.KEY_email + "," +
  59.                 Student.KEY_age +
  60.                 " FROM " + Student.TABLE;
  61.  
  62.         //Student student = new Student();
  63.         ArrayList<HashMap<String, String>> studentList = new ArrayList<HashMap<String, String>>();
  64.  
  65.         Cursor cursor = db.rawQuery(selectQuery, null);
  66.         // looping through all rows and adding to list
  67.  
  68.         if (cursor.moveToFirst()) {
  69.             do {
  70.                 HashMap<String, String> student = new HashMap<String, String>();
  71.                 student.put("id", cursor.getString(cursor.getColumnIndex(Student.KEY_ID)));
  72.                 student.put("name", cursor.getString(cursor.getColumnIndex(Student.KEY_name)));
  73.                 studentList.add(student);
  74.  
  75.             } while (cursor.moveToNext());
  76.         }
  77.  
  78.         cursor.close();
  79.         db.close();
  80.         return studentList;
  81.  
  82.     }
  83.  
  84.     public Student getStudentById(int Id){
  85.         SQLiteDatabase db = dbHelper.getReadableDatabase();
  86.         String selectQuery =  "SELECT  " +
  87.                 Student.KEY_ID + "," +
  88.                 Student.KEY_name + "," +
  89.                 Student.KEY_email + "," +
  90.                 Student.KEY_age +
  91.                 " FROM " + Student.TABLE
  92.                 + " WHERE " +
  93.                 Student.KEY_ID + "=?";// It's a good practice to use parameter ?, instead of concatenate string
  94.  
  95.         int iCount =0;
  96.         Student student = new Student();
  97.  
  98.         Cursor cursor = db.rawQuery(selectQuery, new String[] { String.valueOf(Id) } );
  99.  
  100.         if (cursor.moveToFirst()) {
  101.             do {
  102.                 student.student_ID =cursor.getInt(cursor.getColumnIndex(Student.KEY_ID));
  103.                 student.name =cursor.getString(cursor.getColumnIndex(Student.KEY_name));
  104.                 student.email  =cursor.getString(cursor.getColumnIndex(Student.KEY_email));
  105.                 student.age =cursor.getInt(cursor.getColumnIndex(Student.KEY_age));
  106.  
  107.             } while (cursor.moveToNext());
  108.         }
  109.  
  110.         cursor.close();
  111.         db.close();
  112.         return student;
  113.     }
  114.  

Antwort auf "u"

Hier kannst Du auf den Paste von oben antworten

A PHP Error was encountered

Severity: 8192

Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior

Filename: database/DB_driver.php

Line Number: 1876