|
They're called relations.
Please say you don't do medical equipment.
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
I'm working on a PHP project, that started in SQL server 2000, and I just upgraded the PHP to support SQL Server 2008. Well now I would like to use OFFSET and FETCH to paginate long lists and I need 2012. I'm wondering if just next functions were added or if I need to change my dates again, CONVERT(char(10) createDate, 126) to another format.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
Well, the major one would be that 2012 (v11) is still supported, while 2008 (10.5) isn't.
I don't remember of breaking changes between those versions, though. A slightly better UI for SSMS, maybe. But nothing about date formats which would have changed. I just remember this was the time I started to install db systems on virtual machines rather than on physical ones.
Regarding the date format you are talking about, the only way to be sure is to install a 2012 instance, copy the database, and test your queries and sp's against the new instance.
"Five fruits and vegetables a day? What a joke!
Personally, after the third watermelon, I'm full."
|
|
|
|
|
Yeah your right, give it a test spin, instead of trusting someones word on this. Good call Phil.
I'll call the computer company that created my remote DEV environment and have them ass that. The DB is 26 gigs and it would takes days to get it from a remote machine.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
Well, if you know precisely which datetime fields caused you troubles, you don't need 26 Gb of data.
Having migrated a bunch of servers from MSSQL 2008 to MSSQL 2012, I don't remember having to modify any table, sp or query for it to just work. But, after all, I don't know anything about this database of yours, so these are just my 2 cents.
"Five fruits and vegetables a day? What a joke!
Personally, after the third watermelon, I'm full."
|
|
|
|
|
Your right, if the data is stored the same, then it's just a matter of code adjustments, in which I have already made.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
When you say "convert your dates again" - why are you using strings for dates - surely just casting as a Date would be better?
|
|
|
|
|
I'm working on a project written by 3 Chinese kids from China that were here at UC Irvine to study back in 2000 written in PHP over the course of 8 years. They made some bad choices in database design and I'm not about to change the database since I don't have a full understanding of how the program works. Well I do now after rewriting the PHP since Feb 2021. These kids had disrespect for HTML as well, and the worst programming disciplines I have ever seen.
In PHP 7.4, converting the date to a ISO formatted string speed ed up the process of converting that date into a PHP date object for my Calculation.Factory.PHP to process formulas, which generates the cost of an activity or specific job in the construction industry. And for some reason, technical, writing a PHP date back to SQL server required a different date conversion in SQL.
What was most frustrating was reading a date in SQL, and writing it back to another table in the same format, and SQL server would not write it unless it was in a certain ISO format.
The main point of this project was to get the existing code re imagined and upgraded from PHP 4.2 to PHP 7.4+ to extend the life of the application another 20 years.
I know why the dates had to be converted but I don't know how to work around this without altering the database design at this point in time. Excellent question which is making think about the dates again.
The original SQL did cast the date, but I can't remember at the moment why I had to remove the CAST, that was 8 months ago.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
Hey!!!
Error:
Fatal error: Uncaught Error: Call to a member function fetch_array() on bool
Code:
```
<?php
include('db_connect.php');
session_start();
if(isset($_GET['id'])){
$username = $conn->query("SELECT username FROM users where id =".$_GET['id']);
foreach($username->fetch_array() as $k =>$v){
$meta[$k] = $v;
}
}
?>
Have been wrecking my brain for some days to figure out how to correct this. Can anyone help with rewriting this so it would work properly?
Thank ya!!!
|
|
|
|
|
Your code is vulnerable to SQL Injection[^]. NEVER use string concatenation to build a SQL query. ALWAYS use a parameterized query.
PHP: SQL Injection - Manual[^]
PHP: Prepared statements and stored procedures - Manual[^]
Beyond that, the error suggests that your query didn't work. When the query fails, it returns false rather than a result set, as described in the documentation[^].
There are many possible reasons your query might fail. You will need to debug your code to find out what the problem is and fix it. We can't do that for you.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thank ya for the insight I greatly appreciate it
|
|
|
|
|
The query command is returning a boolean "false", to indicate no record was found. You need to test for that possibility before assuming that you have a valid record. See PHP: mysqli::query - Manual[^].
|
|
|
|
|
Thank ya for the insight..I greatly appreciate it
|
|
|
|
|
Your pretty far off with your code, and I'm not sure which version of PHP your using. Plus your code is very primitive and not object oriented like for PHP versions 7 and up. You have to create a db connector as a class and call that db connector. Then create a query . Next run that query with the db connector which creates a result . The result can be false if nothing comes back, or can be a array of records in which you fetch them. Finally you call that array that was returned and convert them to rows .
I packed the rows into an object that I created, and return the object instead of an array. The code your writing is very the year 2000, and is quite old and outdated. Nobody in western democracies are writing code like that anymore.
PHP 7.4 example, what you should be learning.
Hope that helps you, and PHP Storm by Jet Brains is the preferred editor or IDE for PHP.
<br />
public static function getUsers(): Users {
$users = new Users();
$query = "
SELECT
uid,
Username<br />
FROM [user]
WHERE User_type <> 'xxxxxxx'
ORDER BY Username";
$conn = DbConnectRepository::createConn();
$result = sqlsrv_query($conn, $query) or die(" getUsers " . LINE . " - " . $query . ' - ' . print_r(sqlsrv_errors()));
while ($row = sqlsrv_fetch_array($result)) {
$user = new User();
$user->setUserId($row[0]);
$user->setUserName($row[1]);<br />
$users->add($user);
}
return $users;
}
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
Hey there,
My first time posting on this forum.
I've written and reformed this database a lot over the years. It's written as a C# class library powered by SQLite. It was called metastrings, but that's a dumb name, and I've boiled it down to four operations - UPSERT, SELECT, DELETE, DROP - so 4db made more sense:
GitHub - michaelsballoni/4db: Simple database for high productivity and ease of use
To see how it works, check out the carsdb sample:
4db/carsdb · GitHub
I'd like to get some feedback on the general premise and the implementation.
Thanks, -Michael
|
|
|
|
|
How to write stored procedure in mysql workbench. SELECT, INSERT, UPDATE,DELETE
|
|
|
|
|
|
|
delete
modified 12-Oct-21 8:36am.
|
|
|
|
|
Please don't repost if your question does not appear immediately: all of these went to moderation and required a human being to review them for publication. In order to prevent you being kicked off as a spammer, both had to be accepted, and then I have to clean up the spares. Have a little patience, please!
I've deleted the spare.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
<pre lang="VB">Dim strSql As String = "SELECT DISTINCT Orders.OrderId, Orders.ClientId, OrderDate, DueDate, SubTotal, SalesTax, CityTax, LaborTax, Discount, Delivery, OrderTotal,
OrderDetails.ItemId, OrderDetails.Category, OrderDetails.Description, OrderDetails.Qnty, OrderDetails.Unit, OrderDetails.RetailPrice, OrderDetails.Total, (Select MIN (OrderPymts.PrevBal)) As PrevBal, (Select MAX(OrderPymts.PaymentDate)) As PaymentDate,
(Select MIN (OrderPymts.Payment)) As Payment, (Select MIN (OrderPymts.Balance)) As Balance, OrderPymts.Terms, (Select MAX(OrderPymts.PaymentId)) As PaymentId, Clients.Name,
Clients.Address + ' ' + Clients.City + ', ' + Clients.State + '. ' + Clients.Zip AS ClientsAddress,
'Phone : ' + Clients.Phone + ' Fax : ' + Clients.Fax + ' CellPhone : ' + Clients.CellPhone + ' Email : ' + Clients.Email As ContactInfo, Clients.Since
FROM Orders, Clients
INNER JOIN OrderDetails ON OrderDetails.OrderId = Orders.OrderId
INNER JOIN Clients ON Orders.ClientId = Clients.ClientId
INNER JOIN OrderPymts ON OrderPymts.OrderId = Orders.OrderId
WHERE (Orders.OrderId = @OrderId)"</pre>
I'm having trouble with this statement. This statement is used to call the records in the invoice. Odd since I have 2 records, One with multiple items and only 1 payment and it displays fine. The other record with multiple detail items and multiple payments displays the items twice on the invoice report and shows the first payment record instead of the latest payment record. There are 3 tables, Orders, OrderDetails, and OrderPymts. So I'm trying to query from all three tables based on the orderId.
Any Help would be greatly appreciated.
-- modified 10-Oct-21 22:16pm.
|
|
|
|
|
We can't see the structure of your tables, nor the data they contain.
But what you've described is the expected result of joining multiple records - if you have three lines and two payments for one order, and join them on the order ID, you will get six records in the output.
Visual Representation of SQL Joins[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
How can I post an Image of the Invoice and Tables ?
|
|
|
|
|
You can't.
You can create a small reproduction of your tables using sample data as a SQL Fiddle[^], and post the link to that.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
A real image would be rather weird
What's the structure, and some example data. If you can provide those, then we can "try" your code with your examples and play a bit with it. Without that, we'd have to guess.
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|