Questions tagged [ezsql]

ezSQL is an open-source PHP database class that features a simplified and concise syntax for calling MySQL, Oracle 8/9, InterBase/FireBird, PostgreSQL, SQL Server, and SQLite / SQLite C++ functions within your PHP script.

ezSQL is an open source PHP database class that makes it ridiculously easy to use MySQL, Oracle 8/9, InterBase/FireBird, PostgreSQL, SQL Server, and SQLite / SQLite C++ within your PHP script.

  • It is one PHP file that you include at the top of your script. Then, instead of using standard PHP database functions listed in the PHP manual, you use a much smaller (and easier) set of ezSQL functions.
  • It automatically caches query results and allows you to use easy to understand functions to manipulate and extract them without causing extra server overhead
  • Most ezSQL functions can return results as objects, associative arrays, or numerical arrays

Examples:

Select multiple records from the database and print them out..

$users = $db->get_results("SELECT name, email FROM users");

foreach ( $users as $user )
{
    // Access data using object syntax
    echo $user->name;
    echo $user->email;
}

Get one variable from the database and print it out..

$var = $db->get_var("SELECT count(*) FROM users");
echo $var;
45 questions
35
votes
6 answers

WHERE - IS NULL not working in SQLite?

Here's a strange one: I can filter on NOT NULLS from SQLite, but not NULLS: This works: SELECT * FROM project WHERE parent_id NOT NULL; These don't: SELECT * FROM project WHERE parent_id IS NULL; SELECT * FROM project WHERE parent_id ISNULL;…
Yarin
  • 173,523
  • 149
  • 402
  • 512
15
votes
1 answer

$wpdb - what does it return on fail?

I'm not sure whether this question is WordPress specific or is more related to mySQL. I am trying to find out what would be returned if the transaction with the database fails. In the following scenario, I am updating a row. If none of the values…
Chin
  • 12,582
  • 38
  • 102
  • 152
4
votes
3 answers

Mysql php class recommendation

I have been using ezSQL for the last few years but feel it is outdated. Though I like the simplicity and I like the file based caching ability with json, for small result sets that is. So starting a new project I was looking for suggestions on a…
John
  • 9,840
  • 26
  • 91
  • 137
3
votes
2 answers

Simple database abstraction for PHP and MySQL

This is my very first post here, please let me know if I can improve the question. I'm in the process of updating a website. In short: it handles user subscriptions and keeps track of sales (products I make). I want to keep my options open for…
Fabien Snauwaert
  • 4,995
  • 5
  • 52
  • 70
2
votes
0 answers

ezSQL abnormal behaviour

I am using ezSQL for database queries and connection and sometimes it gives data and sometimes it return no results. Here is the debug code Query [3] -- [SELECT * FROM table WHERE `id`=4] Query Result.. No Results CODE: public function…
Bhumi Shah
  • 9,323
  • 7
  • 63
  • 104
2
votes
1 answer

DISTINCT FROM field but COUNT total

I'm trying to create shortcodes for Wordpress. I would like to display by DISTINCT from 'answer' but COUNT the total from 'answer'. If you find on foreach in my code, I have no idea how to echo the count as I'm using function to return the…
1
vote
0 answers

Using isNull() clears the query in ezSQL

I am using ezSQL's selecting method for extracting data. From a table Table Structure Sample Data Using isNull method in conditions where clause clears the query. While results are stored from previous query. I've tried using query_prepared…
Sudhanshu
  • 21
  • 3
1
vote
1 answer

Grouping WHERE conditions with ezSQL v4 PDO

How can I group my WHERE conditions when using the selecting function? I know how to write it in standard SQL, but I can't work this out using ezSQL. What I'm wanting SELECT user_id, user_password, user_password_key FROM users WHERE (user_login =…
dpDesignz
  • 1,909
  • 10
  • 34
  • 70
1
vote
0 answers

php (ezsql) loop printing wrong value

I hate asking for help with something that seems like it should be obvious but I'm a little lost on this one: I'm trying to set up code that will either search for a student's name, or just display a list of the most recent 100 student files. The…
1
vote
1 answer

Declaration of ezSQL_mysql::query() should be compatible with ezSQLcore::query()

I'm just moving from one server to another. My script was working fine on the old server but I started to get this error on the new server: "Declaration of ezSQL_mysql::query() should be compatible with ezSQLcore::query()" This is the first time…
Hakeem
  • 31
  • 7
1
vote
0 answers

IF/ELSE logic clean-up

I use a library that helps me with db functionality. This is a valid syntax: if ($memID = $db->get_var("SELECT id FROM users WHERE social_id = ".$_SESSION['user'])) { // user found $db->query(" UPDATE users SET …
santa
  • 12,234
  • 49
  • 155
  • 255
1
vote
2 answers

ezSQL insert and return id or row?

I most recently came across ezSQL and thought it's pretty cool. Based on the tutorial, I perform the following to create a new row: $db->query(“INSERT INTO users (name) VALUES ('Amy')”) ; How do i retrieve the id ( assuming auto-increment ) for the…
DjangoRocks
  • 13,598
  • 7
  • 37
  • 52
1
vote
2 answers

ezSQL - Object of class stdClass could not be converted to string

i create my own function with count of data. Here is my function. function Test($data){ global $acc; $count = $acc->get_var("SELECT Count(*) FROM _users WHERE ID='$data'"); if($count == 0) { return true; }else{ …
1
vote
1 answer

Mysql Query is not Working in Php File

I am using original(no-change) ezsql-mysql class in php. my database engine is innodb. everything works great but one query in one page. As I copy the code base from some other working pages everything needed like the classes and functions are…
cerkiner
  • 1,906
  • 10
  • 19
1
vote
1 answer

php code to calculated unread posts in phpbb directly from database

I'm trying to retrieve a specific users unread posts total from a phpbb3 database directly. I'm using ezsql to make my life easier, and I've written the following code based on the following post:…
SRG
  • 35
  • 5
1
2 3