Comments (5)
Hello @Codez1337 ,
You can use $result->num_rows
, it's a property rather than a method but it will hold how many rows the resultset has.
for affected_rows
you have the $db->affected_rows()
method and you should call right after your query.
example:
$result = $db->query("SELECT * FROM users");
echo $result->num_rows; //how many users
$db->query("DELETE from users WHERE active = 0");
echo $db->affected_rows() //how many rows were deleted;
from obj-mysql.
a question which i must ask and may look stupid, but how do you use that in an if statement?
i want to count the rtows and if there are not enough then exit that part of the script. now i know that the old mysql way works but i am trying to get into using classes and oop so how would i do it with this?
I ask because i am getting errors trying to do it the old way.
from obj-mysql.
well its quite simple, properties work like variables, actually this num_rows
is a direct property from the native php mysqli
object.
so you can use it like this
if($result->num_rows==0){
//empty
}
if(!$result->num_rows){
//empty
}
or like this:
if($result->num_rows){
//not empty!
}
from obj-mysql.
so the var i name the query becomes an object?
from obj-mysql.
@Codez1337 , well, yes, it returns a resultset object that helps you access your data
from obj-mysql.
Related Issues (13)
- Add Correct identation, documentation and standarts
- Undefined var in OBJ_mysql.php (line 447) HOT 1
- Could you change UTF-8 to utf8 as default value for charset HOT 1
- Logs might cause memory leak HOT 1
- set correct phpDocBlocks
- Deprecated constructor
- Update value to NULL
- Separate Main class from Result Class.
- Extendend documentation with examples for each method
- Warning when using exit_on_error=false HOT 1
- warning in mysqli_connect HOT 4
- Better error message in case of failed database connection HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from obj-mysql.