您現在的位置是:電腦技術吧?>? 故障問題 ??>??mongodb和php,php框架對mongodb??>??正文詳情

mongodb和php,php框架對mongodb

矯芳澤2019-12-04 09:12:08 人圍觀
簡介mongodb教程本文的例子描述了用PHP實現的mongodb操作類。與您分享以供參考。具體如下:1234567891012131415161718192021222324252mongodb集群

本文實例講述了php實現的mongodb操作類。

分享給大家供大家參考。

具體如下: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 ?php /* * To change this template, choose Tools | Templates * and open the template in the editor. */ class mongo_db { private $config; private $connection; private $db; private $connection_string; private $host; private $port; private $user; private $pass; private $dbname; private $persist; private $persist_key; private $selects = array(); private $wheres = array(); private $sorts = array(); private $limit = 999999; private $offset = 0; private $timeout = 200; private $key = 0; /** * * CONSTRUCTOR * * * Automatically check if the Mongo PECL extension has been installed/enabled. * Generate the connection string and establish a connection to the MongoDB. */ public function __construct() { if((IS_NOSQL != 1)){ return; } if (!class_exists('Mongo')) { //$this-error(The MongoDB PECL extension has not been installed or enabled, 500); } $configs =wxcity_base::load_config(cache,mongo_db); $num = count($configs['connect']); $this-timeout = trim($configs['timeout']); $keys = wxcity_base::load_config('double'); $this-key = $keys['mongo_db']; $this-config = $configs['connect'][$this-key]; $status = $this-connect(); if($status == false) { for($i = 1; $i $num; $i ) { $n = $this-key $i; $key = $n = $num ? $n - $num : $n; $this-config = $configs['connect'][$key]; $status = $this-connect(); if($status!=false) { $keys['mongo_db'] = $key ; $this-key = $key; $data = ?phpnreturn .var_export($keys, true).;n?; file_put_contents(WHTY_PATH.'configs/double.php', $data, LOCK_EX); break; } } } if($status==false) { die('mongoDB not connect'); } } function __destruct() { if((IS_NOSQL != 1)){ return; } if($this-connection) { $this-connection-close(); } } /** * * CONNECT TO MONGODB * * * Establish a connection to MongoDB using the connection string generated in * the connection_string() method. If 'mongo_persist_key' was set to true in the * config file, establish a persistent connection. We allow for only the 'persist' * option to be set because we want to establish a connection immediately. */ private function connect() { $this-connection_string(); $options = array('connect'=true,'timeout'=$this-timeout); try { $this-connection = new Mongo($this-connection_string, $options); $this-db = $this-connection-{$this-dbname}; return($this); } catch (MongoConnectionException $e) { return false; } } /** * * BUILD CONNECTION STRING * * * Build the connection string from the config file. */ private function connection_string() { $this-host = trim($this-config['hostname']); $this-port = trim($this-config['port']); $this-user = trim($this-config['username']); $this-pass = trim($this-config['password']); $this-dbname = trim($this-config['database']); $this-persist = trim($this-config['autoconnect']); $this-persist_key = trim($this-config['mongo_persist_key']); $connection_string = mongodb://; if (emptyempty($this-host)) { $this-error(The Host must be set to connect to MongoDB, 500); } if (emptyempty($this-dbname)) { $this-error(The Database must be set to connect to MongoDB, 500); } if (!emptyempty($this-user) !emptyempty($this-pass)) { $connection_string .= {$this-user}:{$this-pass}@; } if (isset($this-port) !emptyempty($this-port)) { $connection_string .= {$this-host}:{$this-port}; } else { $connection_string .= {$this-host}; } $this-connection_string = trim($connection_string); } /** * * Switch_db * * * Switch from default database to a different db */ public function switch_db($database = '') { if (emptyempty($database)) { $this-error(To switch MongoDB databases, a new database name must be specified, 500); } $this-dbname = $database; try { $this-db = $this-connection-{$this-dbname}; return(TRUE); } catch (Exception $e) { $this-error(Unable to switch Mongo Databases: {$e-getMessage()}, 500); } } /** * * SELECT FIELDS * * * Determine which fields to include OR which to exclude during the query process. * Currently, including and excluding at the same time is not available, so the * $includes array will take precedence over the $excludes array. If you want to * only choose fields to exclude, leave $includes an empty array(). * * @usage: $this-mongo_db-select(array('foo', 'bar'))-get('foobar'); */ public function select($includes = array(), $excludes = array()) { if (!is_array($includes)) { $includes = array(); } if (!is_array($excludes)) { $excludes = array(); } if (!emptyempty($includes)) { foreach ($includes as $col) { $this-selects[$col] = 1; } } else { foreach ($excludes as $col) { $this-selects[$col] = 0; } } return($this); } /** * * WHERE PARAMETERS * * * Get the documents based on these search parameters. The $wheres array should * be an associative array with the field as the key and the value as the search * criteria. * * @usage = $this-mongo_db-where(array('foo' = 'bar'))-get('foobar'); */ public function where($wheres = array()) { foreach ((array)$wheres as $wh = $val) { $this-wheres[$wh] = $val; } return($this); } /** * * WHERE_IN PARAMETERS * * * Get the documents where the value of a $field is in a given $in array(). * * @usage = $this-mongo_db-where_in('foo', array('bar', 'zoo', 'blah'))-get('foobar'); */ public function where_in($field = , $in = array()) { $this-where_init($field); $this-wheres[$field]['$in'] = $in; return($this); } /** * * WHERE_NOT_IN PARAMETERS * * * Get the documents where the value of a $field is not in a given $in array(). * * @usage = $this-mongo_db-where_not_in('foo', array('bar', 'zoo', 'blah'))-get('foobar'); */ public function where_not_in($field = , $in = array()) { $this-where_init($field); $this-wheres[$field]['$nin'] = $in; return($this); } /** * * WHERE GREATER THAN PARAMETERS * * * Get the documents where the value of a $field is greater than $x * * @usage = $this-mongo_db-where_gt('foo', 20); */ public function where_gt($field = , $x) { $this-where_init($field); $this-wheres[$field]['$gt'] = $x; return($this); } /** * * WHERE GREATER THAN OR EQUAL TO PARAMETERS * * * Get the documents where the value of a $field is greater than or equal to $x * * @usage = $this-mongo_db-where_gte('foo', 20); */ public function where_gte($field = , $x) { $this-where_init($field); $this-wheres[$field]['$gte'] = $x; return($this); } /** * * WHERE LESS THAN PARAMETERS * * * Get the documents where the value of a $field is less than $x * * @usage = $this-mongo_db-where_lt('foo', 20); */ public function where_lt($field = , $x) { $this-where_init($field); $this-wheres[$field]['$lt'] = $x; return($this); } /** * * WHERE LESS THAN OR EQUAL TO PARAMETERS * * * Get the documents where the value of a $field is less than or equal to $x * * @usage = $this-mongo_db-where_lte('foo', 20); */ public function where_lte($field = , $x) { $this-where_init($field); $this-wheres[$field]['$lte'] = $x; return($this); } /** * * WHERE BETWEEN PARAMETERS * * * Get the documents where the value of a $field is between $x and $y * * @usage = $this-mongo_db-where_between('foo', 20, 30); */ public function where_between($field = , $x, $y) { $this-where_init($field); $this-wheres[$field]['$gte'] = $x; $this-wheres[$field]['$lte'] = $y; return($this); } /** * * WHERE BETWEEN AND NOT EQUAL TO PARAMETERS * * * Get the documents where the value of a $field is between but not equal to $x and $y * * @usage = $this-mongo_db-where_between_ne('foo', 20, 30); */ public function where_between_ne($field = , $x, $y) { $this-where_init($field); $this-wheres[$field]['$gt'] = $x; $this-wheres[$field]['$lt'] = $y; return($this); } /** * * WHERE NOT EQUAL TO PARAMETERS * * * Get the documents where the value of a $field is not equal to $x * * @usage = $this-mongo_db-where_between('foo', 20, 30); */ public function where_ne($field = , $x) { $this-where_init($field); $this-wheres[$field]['$ne'] = $x; return($this); } /** * * WHERE OR * * * Get the documents where the value of a $field is in one or more values * * @usage = $this-mongo_db-where_or('foo', array( 'foo', 'bar', 'blegh' ); */ public function where_or($field = , $values) { $this-where_init($field); $this-wheres[$field]['$or'] = $values; return($this); } /** * * WHERE AND * * * Get the documents where the elements match the specified values * * @usage = $this-mongo_db-where_and( array ( 'foo' = 1, 'b' = 'someexample' ); */ public function where_and($elements_values = array()) { foreach ((array)$elements_values as $element = $val) { $this-wheres[$element] = $val; } return($this); } /** * * WHERE MOD * * * Get the documents where $field % $mod = $result * * @usage = $this-mongo_db-where_mod( 'foo', 10, 1 ); */ public function where_mod($field, $num, $result) { $this-where_init($field); $this-wheres[$field]['$mod'] = array($num, $result); return($this); } /** * * Where size * * * Get the documents where the size of a field is in a given $size int * * @usage : $this-mongo_db-where_size('foo', 1)-get('foobar'); */ public function where_size($field = , $size = ) { $this-_where_init($field); $this-wheres[$field]['$size'] = $size; return ($this); } /** * * LIKE PARAMETERS * * * Get the documents where the (string) value of a $field is like a value. The defaults * allow for a case-insensitive search. * * @param $flags * Allows for the typical regular expression flags: * i = case insensitive * m = multiline * x = can contain comments * l = locale * s = dotall, . matches everything, including newlines * u = match unicode * * @param $enable_start_wildcard * If set to anything other than TRUE, a starting line character ^ will be prepended * to the search value, representing only searching for a value at the start of * a new line. * * @param $enable_end_wildcard * If set to anything other than TRUE, an ending line character $ will be appended * to the search value, representing only searching for a value at the end of * a line. * * @usage = $this-mongo_db-like('foo', 'bar', 'im', FALSE, TRUE); */ public function like($field = , $value = , $flags = i, $enable_start_wildcard = TRUE, $enable_end_wildcard = TRUE) { $field = (string) trim($field); $this-where_init($field); $value = (string) trim($value); $value = quotemeta($value); if ($enable_start_wildcard !== TRUE) { $value = ^ . $value; } if ($enable_end_wildcard !== TRUE) { $value .= $; } $regex = /$value/$flags; $this-wheres[$field] = new MongoRegex($regex); return($this); } public function wheres($where){ $this-wheres = $where; } /** * * ORDER BY PARAMETERS * * * Sort the documents based on the parameters passed. To set values to descending order, * you must pass values of either -1, FALSE, 'desc', or 'DESC', else they will be * set to 1 (ASC). * * @usage = $this-mongo_db-where_between('foo', 20, 30); */ public function order_by($fields = array()) { if (!is_array($fields) || !count($fields)) return ; foreach ($fields as $col = $val) { if ($val == -1 || $val === FALSE || strtolower($val) == 'desc') { $this-sorts[$col] = -1; } else { $this-sorts[$col] = 1; } } return($this); } /** * * LIMIT DOCUMENTS * * * Limit the result set to $x number of documents * * @usage = $this-mongo_db-limit($x); */ public function limit($x = 99999) { if ($x !== NULL is_numeric($x) $x = 1) { $this-limit = (int) $x; } return($this); } /** * * OFFSET DOCUMENTS * * * Offset the result set to skip $x number of documents * * @usage = $this-mongo_db-offset($x); */ public function offset($x = 0) { if ($x !== NULL is_numeric($x) $x = 1) { $this-offset = (int) $x; } return($this); } /** * * GET_WHERE * * * Get the documents based upon the passed parameters * * @usage = $this-mongo_db-get_where('foo', array('bar' = 'something')); */ public function get_where($collection = , $where = array(), $limit = 99999, $orderby=array()) { if (is_array($orderby) || !emptyempty($orderby)) { $order_by = $this-order_by($order_by); } return($this-where($where)-limit($limit)-get($collection)); } public function selectA($collection = , $limit = 99999, $orderby=array()) { if(intval($limit)1){ $limit = 999999; } $order_by = $this-order_by($orderby); $re = $this-limit($limit)-get($collection); $this-clear(); return (array)$re; } public function listinfo($collection = , $orderby=array(), $page=1, $pagesize=12) { $page = max(intval($page), 1); $offset = $pagesize * ($page - 1); $pagesizes = $offset $pagesize; $this-offset($offset); $order_by = $this-order_by($orderby); $re = $this-limit($pagesize)-get($collection); $this-limit(999999); $count = $this-count($collection); $this-pages = pages($count, $page, $pagesize); return (array)$re; } /** * * GET * * * Get the documents based upon the passed parameters * * @usage = $this-mongo_db-get('foo', array('bar' = 'something')); */ public function get($collection = ) { if (emptyempty($collection)) { $this-error(In order to retreive documents from MongoDB, a collection name must be passed, 500); } $results = array(); $documents = $this-db-{$collection}-find($this-wheres, $this-selects)-limit((int) $this-limit)-skip((int) $this-offset)-sort($this-sorts); $returns = array(); foreach ($documents as $doc): $returns[] = $doc; endforeach; return($returns); } public function getMy($collection = ) { if (emptyempty($collection)) { $this-error(In order to retreive documents from MongoDB, a collection name must be passed, 500); } $results = array(); $documents = $this-db-{$collection}-find($this-wheres, $this-selects)-limit((int) $this-limit)-skip((int) $this-offset)-sort($this-sorts); $returns = array(); foreach ($documents as $doc): $returns[] = $doc; endforeach; $this - clear(); return($returns); } /** * * COUNT * * * Count the documents based upon the passed parameters * * @usage = $this-mongo_db-get('foo'); */ public function count($collection = ) { if (emptyempty($collection)) { $this-error(In order to retreive a count of documents from MongoDB, a collection name must be passed, 500); } $count = $this-db-{$collection}-find($this-wheres)-limit((int) $this-limit)-skip((int) $this-offset)-count(); $this-clear(); return($count); } /** * * INSERT * * * Insert a new document into the passed collection * * @usage = $this-mongo_db-insert('foo', $data = array()); */ public function insert($collection = , $data = array(), $name='ID') { if (emptyempty($collection)) { $this-error(No Mongo collection selected to insert into, 500); } if (count($data) == 0 || !is_array($data)) { $this-error(Nothing to insert into Mongo collection or insert is not an array, 500); } try { /** wxcity_base::load_sys_class('whtysqs','',0); $mongoseq_class = new whtysqs('creaseidsqs'); $re = $mongoseq_class-query(?name= . $collection . opt=putdata=1); **/ $re = put_sqs('list_mongo_creaseidsqs','1'); if(is_numeric($re)){ $re ; $data[$name] = intval($re); }else{ $data[$name] = intval(time()); //die('mongosqs error'); } $this-db-{$collection}-insert($data, array('fsync' = TRUE)); $this-clear(); return $data[$name]; } catch (MongoCursorException $e) { $this-error(Insert of data into MongoDB failed: {$e-getMessage()}, 500); } } public function insertWithId($collection = , $data = array()) { if (emptyempty($collection)) { $this-error(No Mongo collection selected to insert into, 500); } if (count($data) == 0 || !is_array($data)) { $this-error(Nothing to insert into Mongo collection or insert is not an array, 500); } try { $this-db-{$collection}-insert($data, array('fsync' = TRUE)); $this-clear(); return 1; } catch (MongoCursorException $e) { $this-error(Insert of data into MongoDB failed: {$e-getMessage()}, 500); } } /** * * UPDATE * * * Update a document into the passed collection * * @usage = $this-mongo_db-update('foo', $data = array()); */ public function update($collection = , $data = array()) { if (emptyempty($collection)) { $this-error(No Mongo collection selected to update, 500); } if (count($data) == 0 || !is_array($data)) { $this-error(Nothing to update in Mongo collection or update is not an array, 500); } try { $this-db-{$collection}-update($this-wheres, array('$set' = $data), array('fsync' = TRUE, 'multiple' = FALSE)); $this-clear(); return(TRUE); } catch (MongoCursorException $e) { $this-error(Update of data into MongoDB failed: {$e-getMessage()}, 500); } } /** * * UPDATE_ALL * * * Insert a new document into the passed collection * * @usage = $this-mongo_db-update_all('foo', $data = array()); */ public function update_all($collection = , $data = array()) { if (emptyempty($collection)) { $this-error(No Mongo collection selected to update, 500); } if (count($data) == 0 || !is_array($data)) { $this-error(Nothing to update in Mongo collection or update is not an array, 500); } try { $this-db-{$collection}-update($this-wheres, array('$set' = $data), array('fsync' = TRUE, 'multiple' = TRUE)); return(TRUE); } catch (MongoCursorException $e) { $this-error(Update of data into MongoDB failed: {$e-getMessage()}, 500); } } /** * * DELETE * * * delete document from the passed collection based upon certain criteria * * @usage = $this-mongo_db-delete('foo', $data = array()); */ public function delete($collection = ) { if (emptyempty($collection)) { $this-error(No Mongo collection selected to delete from, 500); } try { $this-db-{$collection}-remove($this-wheres, array('fsync' = TRUE, 'justOne' = TRUE)); $this-clear(); return(TRUE); } catch (MongoCursorException $e) { $this-error(Delete of data into MongoDB failed: {$e-getMessage()}, 500); } } /** * * DELETE_ALL * * * Delete all documents from the passed collection based upon certain criteria * * @usage = $this-mongo_db-delete_all('foo', $data = array()); */ public function delete_all($collection = ) { if (emptyempty($collection)) { $this-error(No Mongo collection selected to delete from, 500); } try { $this-db-{$collection}-remove($this-wheres, array('fsync' = TRUE, 'justOne' = FALSE)); return(TRUE); } catch (MongoCursorException $e) { $this-error(Delete of data into MongoDB failed: {$e-getMessage()}, 500); } } /** * * ADD_INDEX * * * Ensure an index of the keys in a collection with optional parameters. To set values to descending order, * you must pass values of either -1, FALSE, 'desc', or 'DESC', else they will be * set to 1 (ASC). * * @usage = $this-mongo_db-add_index($collection, array('first_name' = 'ASC', 'last_name' = -1), array('unique' = TRUE)); */ public function add_index($collection = , $keys = array(), $options = array()) { if (emptyempty($collection)) { $this-error(No Mongo collection specified to add index to, 500); } if (emptyempty($keys) || !is_array($keys)) { $this-error(Index could not be created to MongoDB Collection because no keys were specified, 500); } foreach ($keys as $col = $val) { if ($val == -1 || $val === FALSE || strtolower($val) == 'desc') { $keys[$col] = -1; } else { $keys[$col] = 1; } } if ($this-db-{$collection}-ensureIndex($keys, $options) == TRUE) { $this-clear(); return($this); } else { $this-error(An error occured when trying to add an index to MongoDB Collection, 500); } } /** * * REMOVE_INDEX * * * Remove an index of the keys in a collection. To set values to descending order, * you must pass values of either -1, FALSE, 'desc', or 'DESC', else they will be * set to 1 (ASC). * * @usage = $this-mongo_db-remove_index($collection, array('first_name' = 'ASC', 'last_name' = -1)); */ public function remove_index($collection = , $keys = array()) { if (emptyempty($collection)) { $this-error(No Mongo collection specified to remove index from, 500); } if (emptyempty($keys) || !is_array($keys)) { $this-error(Index could not be removed from MongoDB Collection because no keys were specified, 500); } if ($this-db-{$collection}-deleteIndex($keys, $options) == TRUE) { $this-clear(); return($this); } else { $this-error(An error occured when trying to remove an index from MongoDB Collection, 500); } } /** * * REMOVE_ALL_INDEXES * * * Remove all indexes from a collection. * * @usage = $this-mongo_db-remove_all_index($collection); */ public function remove_all_indexes($collection = ) { if (emptyempty($collection)) { $this-error(No Mongo collection specified to remove all indexes from, 500); } $this-db-{$collection}-deleteIndexes(); $this-clear(); return($this); } /** * * LIST_INDEXES * * * Lists all indexes in a collection. * * @usage = $this-mongo_db-list_indexes($collection); */ public function list_indexes($collection = ) { if (emptyempty($collection)) { $this-error(No Mongo collection specified to remove all indexes from, 500); } return($this-db-{$collection}-getIndexInfo()); } /** * * DROP COLLECTION * * * Removes the specified collection from the database. Be careful because this * can have some very large issues in production! */ public function drop_collection($collection = ) { if (emptyempty($collection)) { $this-error(No Mongo collection specified to drop from database, 500); } $this-db-{$collection}-drop(); return TRUE; } /** * * CLEAR * * * Resets the class variables to default settings */ private function clear() { $this-selects = array(); $this-wheres = array(); $this-limit = NULL; $this-offset = NULL; $this-sorts = array(); } /** * * WHERE INITIALIZER * * * Prepares parameters for insertion in $wheres array(). */ private function where_init($param) { if (!isset($this-wheres[$param])) { $this-wheres[$param] = array(); } } public function error($str, $t) { echo $str; exit; } } ?

版權聲明:本文由 矯芳澤 整理編輯。

原標題:php連接mongodb,redis php

轉載注明出處:http://www.dn9ww09s.icu/fault/15083.html

文章評論

    共有條評論來說兩句吧...

    用戶名:

    驗證碼:

作者推薦

  • code函數,code函數的使用方法

    code函數,code函數的使用方法 相關圖片vscode查看函數調用者authcode函數被許多人使用。它來自discuz程序。它用于加密和解密字符串。您可以設置密鑰和過期時間,這在很多情況下都會用到。原始函數代碼可能會生成諸如“ma...

  • 格式化php,php時間格式化

    格式化php,php時間格式化 相關圖片js格式化在JS中保存和編寫模板有很多場景,比如彈出類型的HTML代碼模板。JS不支持換行的長文本編寫方法,必須加一行。例如,代碼如下:VAR content='divrjson格式化...

  • 刪除目錄,linux刪除指定目錄

    刪除目錄,linux刪除指定目錄 相關圖片Linux如何刪除目錄本文的示例描述如何在PHP中刪除指定的目錄。與您分享以供參考。具體分析如下:該代碼可以實現遞歸刪除子目錄1234567891013141516171819201Linux 刪除所有目錄...

  • 日期格式怎么轉換,表格怎么轉換日期格式

    日期格式怎么轉換,表格怎么轉換日期格式 相關圖片excel日期格式轉換為數字格式此代碼可以將時間格式設置為3天前、5秒前和2年前1234567891013141516171819201222324252627282930131233//excel日期格式轉換不了...

  • 單撇號,上撇號怎么打

    單撇號,上撇號怎么打 相關圖片撇號例如:echo'whoamI';//要導出數據庫,要導入的文件夾必須具有可寫權限。在-U-P之后的內容必須寫在以下代碼的旁邊:echo`mysqldump-H 前面有撇號...

  • 遞歸生成樹形結構,遞歸生成html

    遞歸生成樹形結構,遞歸生成html 相關圖片java遞歸生成樹形菜單要編寫遞歸函數,可以考慮緩存并定義一些靜態變量來存儲上次運行的結果。多道程序設計的效率是非常有幫助的。具體步驟如下:首先從數據庫中獲取數據,放入...

  • php實例大全,php實例開發

    php實例大全,php實例開發 相關圖片php實例代碼本文主要介紹了PHP的兩種無限分類實例。本文給出了用遞歸法和非遞歸法實現無限分類的實例。對于朋友,請參考以下代碼:items=array(array('id'=php中文教程...

  • 連接sqlserver數據庫失敗,sqlserver連接數據庫

    連接sqlserver數據庫失敗,sqlserver連接數據庫 相關圖片SQL數據庫連接不上ASP教程中連接SQL Server數據庫的兩種方法本教程主要討論連接ASP和mssqlserver數據庫的兩種不同方法,主要是sqlserver連接方法和sqsql server連接到服務器...

  • 什么叫做函數,函數有哪些

    什么叫做函數,函數有哪些 相關圖片具體函數給定一個時間,計算這個時間是多久以前的,例如:兩天前,一年前12345678910131415161718192021222324252627293013234函數的表示...

  • 快速排序php,php快速排序冒泡排序

    快速排序php,php快速排序冒泡排序 相關圖片python快速排序算法本文通過一個實例說明如何在PHP中實現快速排序。與您分享以供參考。具體實現方法如下:1234567891012131415161718函數快速排序($SEQ){php排序...

熱評文章

  • php轉換html,php格式怎么轉換

    php轉換html,php格式怎么轉換 相關圖片php轉換文本編碼具體如下:PHP圖片轉換成ASCII碼,轉換后圖片1234567891013141516171819201222324252627282933132333435php轉換字符編碼...

  • php字符串,php字符串替換

    php字符串,php字符串替換 相關圖片php 字符串長度具體如下:123456789101213141516171819201222324252627282933132334353738394041424344454php字符串反轉...

  • asp增加數據,asp顯示數據

    asp增加數據,asp顯示數據 相關圖片asp連接數據表格ASP data cast CBool(expression)cbyte(expression)ccur(expression)CDate(expressionasp最大生成數據...

  • asp 代碼,asp開源代碼

    asp 代碼,asp開源代碼 相關圖片怎樣將asp源代碼%調暗CC?信息(4)、strinfo、strtemp if會話(CC?信息)=然后CC?信息(0)=CC log.txt'日志文件名CC?信息(1)=請求服務什么是asp...

  • php獲取網頁內容,php獲取網頁源碼

    php獲取網頁內容,php獲取網頁源碼 相關圖片php訪問網頁本文的示例描述了PHP如何獲取web頁面上的所有鏈接。與您分享以供參考。具體實現方法如下:代碼如下:?Phpfunction get all URL($code獲取網頁html...

  • 設置服務器時間,怎么設置時間服務器

    設置服務器時間,怎么設置時間服務器 相關圖片如何防止服務器更改時間具體如下:這里,strftime函數主要用來實現這個函數,代碼非常簡單,如下:12$today=date('y-m-d-g');$today=strftime(gdc服務器調整時間密碼...

  • 數據庫和程序如何連接,數據庫的連接

    數據庫和程序如何連接,數據庫的連接 相關圖片數據庫連接失敗在網上搜索大量的信息,經過他們不懈的努力,終于測試成功。最初,您需要在服務器上安裝MySQL ODBC 3.51以及數據庫用戶名和密碼。使用以下密碼。以下是引用web怎么連...

  • 當前訪問頁面升級中,python訪問集合

    當前訪問頁面升級中,python訪問集合 相關圖片python集合元素訪問cookies的值比其他ASP集合(如form和ServerVariables)的值復雜得多。cookie是瀏覽器存儲在客戶機系統上的一小段文本,與每個請求一起緊急頁面升級 每天正常訪問...

  • 字符在字符串出現的次數,字符串出現最多的字符

    字符在字符串出現的次數,字符串出現最多的字符 相關圖片統計字符串中每個字符出現的次數使用此函數返回字符串中字符或字符串的出現次數,其中Mainstr是要搜索的字符串,substr是要檢查的字符串。函數countinstances(Mainstr輸入一個字符串...

  • 存儲過程調用,如何調用存儲過程

    存儲過程調用,如何調用存儲過程 相關圖片sql存儲過程調用使用SQL server存儲過程可以大大提高程序的運行速度,簡化程序維護的難度,得到了廣泛的應用。存儲過程是可以接受和返回用戶提供的參數的transact-SQsql怎么調用存儲過...

關注微信

变脸官网查询