PHP Classes

DBSQL

Recommend this page to a friend!

      DBSql Class  >  All threads  >  DBSQL  >  (Un) Subscribe thread alerts  
Subject:DBSQL
Summary:how to use this class
Messages:4
Author:trandra
Date:2008-02-25 09:28:36
Update:2008-02-27 02:38:00
 

  1. DBSQL   Reply   Report abuse  
Picture of trandra trandra - 2008-02-25 09:28:41
how to use function Query($query,$data=array()) ?

  2. Re: DBSQL   Reply   Report abuse  
Picture of meth meth - 2008-02-25 18:46:58 - In reply to message 1 from trandra
The Query function is very easy to use, ex:

$db->Query('SELECT * FROM my_table WHERE MyField = ?',array($valueOfField));

This is used to prevent SQL Injection. You can use ? in the Query to substitue it for the data passed through the array.

  3. Re: DBSQL   Reply   Report abuse  
Picture of trandra trandra - 2008-02-26 06:18:11 - In reply to message 2 from meth
Can you help me because I am very hopeless in php but I want to use your Class because I see it very good.


I have this table rslangue(idLangue,Langue) and 4 data.

This is my script:

<?php
require_once ('dbsql.class.php');
$conn=new DBSQL('mysql','localhost','root','','dbomef');
$sql_stat="select * from rslangue";
$valueOfField="Francais";
$conn->Query('SELECT * FROM rslangue WHERE Langue = ?',array($valueOfField));
?>

and I have this error on navigator:

Notice: Undefined offset: 1 in G:\EasyPHP 2.0b1\www\model\dbsql.class.php on line 211


How to display all data in my table rslangue

  4. Re: DBSQL   Reply   Report abuse  
Picture of meth meth - 2008-02-27 02:38:00 - In reply to message 3 from trandra
Try with this code:

<?php
require_once ('dbsql.class.php');
$conn=new DBSQL('mysql','localhost','root','','dbomef');
$conn->Query('SELECT * FROM rslangue WHERE Langue = ?',array('Francais'));
?>