Jump to content

Search the Community

Showing results for tags 'db'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 9 results

  1. Hi Phreaks, I hope you've all made it through the weekend with sound body and mind. The following 2 methods have been working together harmoniously for quite a while: <?php public function action($action, $table, $where = [], $rule = "") { if(count($where) === 3) { $operators = array('=', '<', '>', '<=', '<='); $field = $where[0]; $operator = $where[1]; $value = $where[2]; if(in_array($operator, $operators)) { if($rule == "") { $sql = "{$action} FROM {$table} WHERE {$field} {$operator} ?"; } else { $sql = "{$action} FROM {$table} WHERE {$field} {$operator} ? {$rule}"; } if(!$this->query($sql, array($value))->error()) { return $this; } } return false; } public function get($table, $where = [], $rule = "", $column = "*") { return $this->action("SELECT {$column}", $table, $where, $rule); } My original belief was that it was easily extensible. I'm now to the point I'm trying to do that and receiving behaviour that I don't understand. If the action() method becomes thus -> <?php public function action($action, $table, $where = [], $rule = "") { if(count($where) === 3) { $operators = array('=', '<', '>', '<=', '<='); $field = $where[0]; $operator = $where[1]; $value = $where[2]; if(in_array($operator, $operators)) { if($rule == "") { $sql = "{$action} FROM {$table} WHERE {$field} {$operator} ?"; } else { $sql = "{$action} FROM {$table} WHERE {$field} {$operator} ? {$rule}"; } if(!$this->query($sql, array($value))->error()) { return $this; } } } else { $sql = "{$action} FROM {$table}"; echo "this <br>"; return $this; } echo "false <br>"; return false; } with the added else{} statement to handle queries without WHERE conditions, and call it with just the $table parameter -> <?php public function get() { // $table = "posts"; $table = "categories"; $field = "*"; $query = $this->_db->get($table); // print_r($query); var_dump($query); } //normally, using conditions, it would look like this: $query = $this->_db->get($table, array($field, "=", $value); It returns: which we can see is picking up my else{} statement as it should but is returning this empty object. Could someone explain this to me? thank you
  2. This is posting to any row in mssql that has a matching 'start_date'. I would like it to post rows where start_date = '$start_date' and it also matches the 'meter_id' . It should perform this check of both parameters before posting to mssql. <?php $session_id = $_SESSION['id']; $comm_id = $_GET['meter_id']; $start_date = $_GET['start_date']; $payment_date = $_POST['payment_date']; $amount_paid = $_POST['amount_paid']; $check_number = $_POST['check_number']; $sql = "UPDATE [radiogates].[dbo].[ops_invoice_history] SET payment_date = '$payment_date', amount_paid = '$amount_paid', check_number = '$check_number' where start_date = '$start_date'"; $query = sqlsrv_query($conn, $sql); Thank you for any help.
  3. Hello everyone! I am trying to insert a student into a table (with TIMESTAMP; works with VARCHAR, not TIMESTAMP). Can anyone help? Variable $time_stamp = date("D M j G:i:s T Y"); Populate DB Query ("DROP TABLE IF EXISTS enrolled") || !$link->query("CREATE TABLE enrolled(course_id VARCHAR(50), student_id VARCHAR(50), user_ip VARCHAR(50), time_stamp TIMESTAMP(6)) Insert Query INSERT INTO enrolled(course_id,student_id,user_ip,time_stamp) VALUES('$course','$number','$user_ip','$time_stamp')
  4. Hello, i need some help/info about searching words in files (txt or xml) and saving them to db or another file. For example ive got an xml file like below: <families> <family> <name>brown</name> <city>denver</city> <members>12</members> </family> <family> <name>jackson</name> <city>new york</city> <members>6</members> </family> </families> i want to search for: <family> then save the lines till it comes to the word </family> and then goes to the next group. did some reading about array, preg_match, strpos functions but dont know where to start. what is the best way to do this? can you guys give me some advise... or links to good tutorials? thanks in advance!
  5. Here is the deal, its a simple script. 1-read a site link from a sql table**(sql1) 2-mark the sql1 line as read 3-goes to the site and capture several pieces of data(i used curl) 4-modify the read data 5-writes the data in another sql(sql2) So i did this with a few links, but i have to do this with 5~10 millions of links, what would be the better way to get performance and speed?
  6. I am working on a small form that retrieves and stores values to a DB. I want to retrieve the contents of a table and use it in a drop down box. The code I have used is: <?php // Connect to the db. require ('mysqli_connect.php'); // Make the query: $q = "SELECT employee_name from employee where dept_id=3 ORDER BY employee_id ASC"; // Run the query. $r = mysqli_query ($dbc, $q); if ($r) // If it ran OK, display the records. { echo '<select name="employee_name">'; // Fetch and print all the records: while ($row = mysqli_fetch_array($r)) { echo '<option value="'.$row['employee_name'] . '>"'.$row['employee_name'] .'</option>'; } echo "</select>"; } mysqli_free_result ($r); // Free up the resources. mysqli_close($dbc); // Close the database connection. ?> The code works perfectly in MySQL console. But, it returns an empty drop down box in the webpage. Guys, please help.
  7. Hello. I am one of the millions of noobs out there. I have a script designed to look up database and return search results to a table. The page however is blank so nothing is being output at all. Even the source is empty when I look at it. So the script starts with a simple index page to enter the search term and then submit. The search.php page then has the following parsed into the browser url = search.php?query=death&submit=Search I have tried searching google for all sorts of reasons for blank pages but none appear to help as they all appear to be unrelated. the script i am using on the search page is below, I want to learn so some pointers would be useful please. <?php mysql_connect("localhost", "user", "password") mysql_select_db("db") or die(mysql_error()); $query = $_GET['query']; $min_length = 1; if(strlen($query) >= $min_length) { $query = htmlspecialchars($query); $query = mysql_real_escape_string($query); echo "<table border='0' width='300' align='center'>"; echo "<tr align='center' bgcolor='#002C40' > <td height='35px' width='150px'>Title</td> <td>Author</td></tr>"; $raw_results = mysql_query("SELECT * FROM avathar15 WHERE (`user` LIKE '%".$query."%') OR (`alliance` LIKE '%".$query."%')"); if(mysql_num_rows($raw_results) > 0) { while($results = mysql_fetch_array($raw_results)) { echo "<tr align='center' bgcolor='#0f7ea3'> <td height='25px'>".$results['title']."</td> <td>".$results['text']."</td></tr>" ; } } else{ echo "<tr align='center' bgcolor='#6C0000'> <td colspan='2' height='25px'>No results</td> <tr>"; echo "</table>"; } } else{ echo "Minimum length is ".$min_length; } ?>
  8. Hello, I have 2 databases. One is of my application and the other one is of front-accounting software. Both are in MySQL, but with different schemas totally. My question is: how can I migrate my DB into front-accounting DB? Thanks.
  9. I have a question... I am trying to figure out how I can search my database for the next available spot open, and if it is not available then the next available in another row. My example is this.... If I have name1, name 2, name3, name4, name5 and the data is joe, jon, tim, null, null Also, this is not always the same... I have many tables like this but some have name1, name 2 while some go up to name10. I need one statement to search any one of these.... How can I do a search that says select the open name in that row. If there are no open rows move to next row and check. I was thinking a loop but not sure how that would work. I appreciate the help! I hope this all makes sense!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.